JSP Files Property Editor

Tip Note that this feature might not be included in your version of the IDE. If it is not available, you can edit the deployment descriptor (web.xml) file using the editor of your choice. For more information, see Java Servlet 2.3 Specification available at http://java.sun.com/products/servlet .

The JSP file property editor provides a way to associate a JSP component with a named servlet. All JSP files in a web module are, by default, deployed with the web module. However, if you want the web container to treat the JSP as a named servlet, you must add a JSP file entry. In effect, there is a servlet implementation, which is either a JSP file or a servlet class, and there is a named servlet. Existing only in the context of a web container, the named servlet has a corresponding implementation, either the servlet class or the JSP file, and a set of deployment properties that go beyond the code found in the implementation.

Typically, JSP file properties are not required. You can add JSPs to this list in order to provide named references to the JSP files. A JSP File entry can map to a servlet mapping entry. This mapping is similar to creating a servlet entry in the deployment descriptor and connecting it to a servlet mapping entry.

Each entry in the JSP File property editor corresponds to a <servlet> element with a JSP file implementation. The servlet-name and jsp-file named servlet entries are required. The icon, display-name, and description named servlet entries are optional. The named servlet can have any number of initialization parameters and security role references, or none at all.

To display the JSP Files property editor:

  1. Click the Deployment pane of the web.xml property sheet.
  2. By default, the value field for JSP Files displays No JSP Elements.
  3. Click the value field to make the ellipsis button (...) appear. Then click the ellipsis button.

To add JSP files:

To edit JSP files:

To remove JSP files:

  1. From the JSP Files property editor, click the desired JSP file and the Remove button. The file is removed from the table.
  2. Click OK to confirm the action or Cancel to stop the action.

The Add JSP Files and Edit JSP Files dialog boxes contain text fields and checkboxes for deployment data, an initialization parameters table, and a security role references table.

Deployment Data

Initialization Parameters

You can add, edit, or remove initialization parameters for your JSP file. Each entry corresponds to an <init-param> element in the deployment descriptor

To add an initialization parameter:

  1. Click the Add button in the Init Parameters pane. The Add Init Parameter dialog box appears.
  2. Type the name for the initialization parameter into the Init Param Name text field.
  3. Type in the value for the intialization parameter into the Init Param Value text field.
  4. Type in an optional description of the intialization parameter into the Description text field.
  5. Click OK for the initialization parameter you have described to appear in the Add JSP File dialog box.

To edit an initialization parameter:

  1. Select the desired initialization parameter from the table, and click the Edit button in the Init Parameters pane. The Edit Init Parameter dialog box appears.
  2. Edit the name for the initialization parameter in the Init Param Name text field.
  3. Edit the value for the initialization parameter in the Init Param Value text field.
  4. Edit the description of the intialization parameter in the Description text field.
  5. Click OK for the initialization parameter you have edited to appear in the Add JSP File dialog box.

To remove an initialization parameter:

  1. From the Add JSP File dialog box, select the desired initialization parameter and click the Remove button.
    The initialization parameter is removed from the table.
  2. Click OK to confirm the action or Cancel to stop the action.

Security Role References

A security role reference must be declared when the developer has used programmatic security within the component, in this case, the JSP page. This information is used to determine which resources a user is permitted access to. Resources are defined by the web resource collection.

The security-role-ref element defines a mapping between the name of role called from a servlet using isUserInRole(String name) and the name of a security role defined for the web application.

To test programmatically whether the current user is in a given role, the developer uses the isUserInRole method on the HttpServletRequest object, passing the logical user role name as a parameter. Of course, developer, assemblers, or deployers might not assign the same logical name for a user role. For example, two programmers working on two different servlets might think of the same logical role of administrator, but use different names such as admin and administrator. Therefore, when the servlets are placed in the web module, each servlet declares a security role reference. The deployer can link each of these references to a role name in the deployed web module, for instance, admin, administrator, or a new term, such as sys-admin.

Each entry corresponds to a <security-role-ref> element in the deployment descriptor. Note that the <security-role-ref> refers to a programmatic reference in the JSP/servlet component, but is linked to a web-module-wide <security-role> through the <role-link> child of the <security-role-ref>. In other words, to map the programmatic reference to the web module's role, /web-app/servlet/security-role-ref/role-link == /web-app/security-role/role-name.

You can add a reference to the security role for a JSP file in the Security Role References pane of the Add JSP File dialog box. These security roles could be different from the ones on the Security tab of the Deployment Descriptor properties sheet.

To add a security role reference to the JSP file:

  1. Click the Add button in the Security Role References Pane. The Add Security Role Reference dialog box appears.
  2. Type the desired name for the security role reference in the Role Ref Name text field, followed by an optional description in the Description text field.
  3. Type the desired link to the security role in the Role Ref Link text field, and click OK. The information you have entered now appears in the Security Role Reference pane of the Add JSP File dialog box.

To edit a security role reference:

  1. Select the desired security role reference from the table, and click the Edit button in the Secutity Role Reference pane. The Edit Security Role Reference dialog box appears.
  2. Edit the name for the security role reference in the Role Ref Name text field.
  3. Edit the description of the security role reference in the Description text field.
  4. Edit the link to the security role in the Role Ref Link text field.
  5. Click OK for the security role reference you have edited to appear in the Add JSP File dialog box.

To remove a security role reference:

  1. From the Add JSP File dialog box, click the desired security role reference and the Remove button.
    The security role reference is removed from the table.
  2. Click OK to confirm the action or Cancel to stop the action.
See also
Editing Web Module Deployment Properties
Editing Web Module Security Properties

Legal Notices