The Java EE 6 Tutorial

ProcedureTo Add an Initialization Parameter Using NetBeans IDE

You can use the @WebServlet annotation to specify web component initialization parameters by using the initParams attribute and the @WebInitParam annotation. For example:


@WebServlet(urlPatterns="/MyPattern", initParams=
  {@WebInitParam(name="ccc", value="333")})

Alternatively, you can add an initialization parameter to the web.xml file. To do this using NetBeans IDE, follow these steps.

  1. Open the project if you haven’t already.

  2. Expand the project’s node in the Projects pane.

  3. Expand the Web Pages node and then the WEB-INF node.

  4. Double-click web.xml.

  5. Click Servlets at the top of the editor pane.

  6. Click the Add button under the Initialization Parameters table.

    An Add Initialization Parameter dialog opens.

  7. In the Parameter Name field, type the name of the parameter.

  8. In the Parameter Value Field, type the parameter’s value.

  9. Click OK.