Servlets

Servlet details

Use the servlet pages to describe a servlet class or JSP page used in the Web application. Click New to give the servlet or page a short name that can be used to reference it. Then select Servlet Class or JSP Filename from the drop-down list box. For servlets, you must specify the fully qualified class name in the text box next to the drop-down list box.

If you want to see target JSPs listed in the management tool for your server, you must enter a short name for each JSP, select JSP Filename from the drop-down list box, and enter the JSP file name in the text box next to the drop-down list box. However, this information is not required for access to the JSPs from a client browser.

You can specify the following properties for each servlet or JSP from the Deployment Configuration Properties dialog box: Load on Startup, Init Param, Role references, and Servlet mapping URL pattern.

Load on Startup

Load on Startup indicates whether you want a servlet loaded and initialized when the application is deployed. Otherwise, the servlet class is loaded when the first client requests it. Servlet classes that perform lengthy processing in the init method can be loaded at startup so that the first client to invoke the servlet does not experience increased response time.

A value of 0 or a positive integer requires the container to load the servlet when the application is deployed. Servlets with a low Load on Startup value are loaded before those with a higher value. If you do not specify a value, or if you specify a negative integer, the container can load the servlet at any time.

Init Param

Use the Init Param table to assign values of parameters specifying setup information for the servlet or JSP page. In a JSP page, the parameter can be retrieved in a scriptlet using the config implicit object, for example:

<%
   String initVal = config.getInitParameter("initVal");
%>

Role references

Role references provide a mechanism for an application to map a role name used in the application’s code to a security role defined in its deployed environment.

Table 12-6: Role reference properties for a JSP target

Setting

Value

Name

Name of the security role used as a parameter to the IsCallerInRole method

Description

(Optional) A comment to explain how the property is used

Link

The security role (see “Roles”) to which this reference should be linked

Servlet mapping URL pattern

A servlet mapping defines the association between a URL pattern and a servlet. This mapping is used to map requests to servlets. The default is /ServletTargetName, for example, /MyServlet.

If the container handling the request is a JSP container, a URL containing a .jsp extension is implicitly mapped.