![]() |
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 Servlets property editor provides a way to designate deployment properties for servlet files in the web module. These properties are equivalent to those you specify in the JSP File property editor. However, in this case a servlet class is used for the named servlet implementation rather than a JSP file.
To display the Servlets property editor:
Alternatively, you can edit the deployment properties of a specific servlet in your web module:
To add servlet file deployment data: From the Servlets property editor,
click the Add button.
The Add Servlet dialog box appears.
To edit servlet file deployment data: From the Servlets property editor,
select the desired servlet, and click the Edit button.
The Edit Servlet dialog box appears.
To remove servlet file deployment data: From the Servlets property
editor, click the desired servlet and the Remove button.
The servlet is removed from the table. Click OK to confirm the action or Cancel
to stop the action.
Add Servlet and Edit Servlet dialog boxes: Contain text fields and checkboxes for deployment data, an initialization parameters table, and a security role references table.
To specify a servlet name: Type the desired name in the Servlet Name text field, for instance, FormProcessingServlet. This designation is often the same name as the servlet class. However, the servlet class could have an obscure name such as GenericSearchServlet when you want a more basic name in the web module, for instance, search.
To specify a display name: Type the desired name in the Display Name text field. Like the small and 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.
To provide a description: Type the desired information in the Description text field. This field can be used to provide additional information, such as what the servlet does. The Description field is optional, so you don't have to type anything here. Like the Display Name field, this data is not used by the IDE, but could be used by an external tool.
To specify a servlet class: Enter the desired class in the Servlet Class text field. Click the Browse button to navigate to the desired servlet class using a file chooser. Use the qualified class of the servlet implementation, such as com.myCompany.myProject.GenericSearchServlet.
To designate mappings:
To specify a small or large icon: Use this field to designate external
tools such as a deployment tool that might represent the web module that could
use these icons to represent the 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.
To specify load on startup: Use this field to designate whether the
servlet should load when the web container starts the application. By default,
the servlet does not load upon startup. This information corresponds to optional
<load-on-startup>
element in deployment descriptor.
<init-param>
element in the deployment descriptor.
To add an initialization parameter:
To edit an initialization parameter:
To remove an initialization parameter:
A security role reference must be declared when you have used programmatic security within the component, in this case, the servlet file. This information is used to determine which resources a user is permitted to access. 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, you can use the isUserInRole method on the HttpServletRequest object, passing the logical user role name as a parameter. Of course, developers, 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. Some examples might include 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.
To add a security role reference to the servlet:
To edit a security role reference:
To remove a security role reference:
See also | |
---|---|
Editing Web Module
Deployment
Properties
Editing Web Module Security Properties |