background image

Setting Initialization Parameters

<< Declaring WelcomeFiles | Mapping Errors to Error Screens >>
<< Declaring WelcomeFiles | Mapping Errors to Error Screens >>

Setting Initialization Parameters

a. Click Pages at the top of the editor pane and enter the names of the JSP pages that act as
welcome files in the Welcome Files field.
b. Click XML at the top of the editor pane, specify the JSP pages using welcome-file
elements and include these elements inside a welcome-file-list element. The
welcome-file
element defines the JSP page to be used as the welcome page.
The example discussed in
"Encapsulating Reusable Content Using Tag Files" on page 233
has a welcome file.
Setting Initialization Parameters
The web components in a web module share an object that represents their application context
(see
"Accessing the Web Context" on page 124
). You can pass initialization parameters to the
context or to a web component.
To add a context parameter using NetBeans IDE, do the following:
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 General at the top of the editor pane.
6. Select the Context Parameters node.
7. Click Add.
8. In the Add Context Parameter dialog, do the following:
a. Enter the name that specifies the context object in the Param Name field.
b. Enter the parameter to pass to the context object in the Param Value field.
c. Click OK.
Alternatively, you can edit the XML of the web.xml file directly by clicking XML at the top of the
editor pane and using the following elements to add a context parameter:
A param-name element that specifies the context object
A param-value element that specifies the parameter to pass to the context object
A context-param element that encloses the previous two elements
For a sample context parameter, see the example discussed in
"The Example JSP Pages" on
page 136
.
To add a web component initialization parameter using NetBeans IDE, do the following:
1. Open the project if you haven't already.
2. Expand the project's node in the Projects pane.
Configuring Web Applications
The Java EE 5 Tutorial · September 2007
92