JSP Files Property Editor
 |
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:
- Click the Deployment pane of the web.xml property sheet.
By default, the value field for JSP Files displays No JSP Elements.
- Click the value field to make the ellipsis button (...) appear. Then click
the ellipsis button.
To add JSP files:
- From the JSP Files property editor, click the Add button. The Add JSP File
dialog box appears.
To edit JSP files:
- From the JSP Files property editor, click the desired JSP file and the Edit
button. The Edit JSP File dialog box appears.
To remove JSP files:
- From the JSP Files property editor, click the desired JSP file and the Remove
button. The file is removed from the table.
- 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
- Servlet Name: Type the desired name in the Servlet Name text field.
The web container uses this name to refer to the JSP file. This name can be
used to map the named servlet to a particular URL pattern. Note that this
corresponds to the
<servlet-name>
element in the deployment
descriptor.
- Display Name: As with small or large icons, described below, the
display name is not used within the IDE, but can be specified for use by other
J2EE-compliant tools, such as a deployment tool for a particular web server.
Type the desired name in the Display Name text field. Note that this corresponds
to the optional
<display-name>
element in the deployment
descriptor.
- Description: Provides additional information about the JSP file.
This information might be displayed by an external J2EE tool, such as a deployment
tool. Type the desired information in the Description text field. Note that
this information maps to the optional
<description>
element
in the deployment descriptor.
- JSP File Name: Enter the JSP that is the implementation of the named
servlet in the JSP File text field. Click the Browse button to navigate to
the JSP file using a file chooser. Note that this information maps to the
<jsp-file>
element in the deployment descriptor.
- Servlet mappings: Specify the URL patterns that should be redirected
to this JSP file. Note that each servlet mapping corresponds to a
<servlet-mapping>
element in the deployment descriptor.
- Click the ellipsis button in the Mappings text field to designate the
desired mappings for the JSP file. The Edit Servlet Mappings dialog box
appears.
- Click Add. The Add Servlet Mapping dialog box appears.
- Type the desired servlet name in the Servlet Name text field.
- Type the associated URL pattern in the URL Pattern text field.
- Click OK in this dialog box, and click OK in the Edit Servlet Mappings
dialog box. The designated servlet mappings appear in the Mappings field
of the Add JSP File dialog box.
- Small or large icon:External tools that might represent the web module,
for instance, a deployment tool, could use these icons to represent the named
servlet. Developers can specify the icons to use here, but the icons are not
actually displayed by the IDE. The information in this field corresponds to
the
<large icon>
and <small-icon>
elements
in the deployment descriptor.
- Click the ellipsis button next to the Small Icon (16x16) or Large Icon
(32x32) text field. The Edit Icon dialog box appears.
- In the Image Source pane, you can designate a URL, file name, or class
path to the icon by clicking the appropriate radio button. You can also
indicate that no picture is to be provided by clicking the No picture
radio button.
- Type the correct URL, file name, or class path in the Name text field,
and click OK. The icon information appears in the Add JSP File dialog
box.
- Load On Startup: Designates whether the JSP file should load when
the web container starts the application. By default, the JSP file does not
load upon startup. This information corresponds to the optional
<load-on-startup>
element in the deployment descriptor.
- Click the Load on Startup checkbox to indicate that the JSP file should
be loaded when the web container starts the application. The Order text
field is now editable.
- To change the order in which the web container loads the named servlet
at application startup, type the desired number in the Order text field.
Named servlets are loaded starting from number 1.
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:
- Click the Add button in the Init Parameters pane. The Add Init Parameter
dialog box appears.
- Type the name for the initialization parameter into the Init Param Name
text
field.
- Type in the value for the intialization parameter into the Init Param Value
text field.
- Type in an optional description of the intialization parameter into the
Description text field.
- Click OK for the initialization parameter you have described to appear in
the
Add JSP File dialog box.
To edit an initialization parameter:
- 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.
- Edit the name for the initialization parameter in the Init Param Name text
field.
- Edit the value for the initialization parameter in the Init Param Value text
field.
- Edit the description of the intialization parameter in the Description text
field.
- Click OK for the initialization parameter you have edited to appear in the
Add JSP File dialog box.
To remove an initialization parameter:
- 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.
- 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:
- Click the Add button in the Security Role References Pane. The Add Security
Role Reference dialog box appears.
- 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.
- 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:
- 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.
- Edit the name for the security role reference in the Role Ref Name text
field.
- Edit the description of the security role reference in the Description text
field.
- Edit the link to the security role in the Role Ref Link text field.
- 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:
- 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.
- Click OK to confirm the action or Cancel to stop the action.
Legal Notices