
In addition to the predefined entries, you will now enter specific deployment information about the two Web resources in the J2EE standard descriptor web.xml.
|
Description |
Use |
|
General Descriptions |
|
|
Display Name |
Returns a label for the War file to be created. |
|
Description |
Returns a description for the deployment descriptor as a whole. |
|
Mapping entries |
|
|
URL pattern |
Defines symbolic names for the JSP file and for the servlet. This approach has an advantage over directly calling the file names, in that the name of the components can be changed without your having to adapt the source code accordingly. |
|
Reference entries |
|
|
EJB local references |
Contains a local reference name for the session bean QuickOrderProcessorBean. This reference name must match the call in the servlet. |
|
|
The structure of your Web Module project QuickCarRentalWeb is currently displayed in the J2EE Explorer. |
Specifying the general properties
The Developer Studio opens a multipage editor, which allows you to enter descriptions in the standard deployment descriptor web.xml.
These entries are automatically added to the XML source at the appropriate point.
<web-app> <display-name>Rent-A-Car</display-name> <description>Web resources for car rental example.</description> ... </web-app>
Defining a URL pattern
|
Servlet Name |
URL Pattern |
|
QuickReservationServlet |
/ |
|
quickCarRentalView.jsp |
/view |
The following entries are automatically added to the XML source:
<web-app> ... <servlet-mapping> <servlet-name>QuickReservationServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>quickCarRentalView.jsp</servlet-name> <url-pattern>/view</url-pattern> </servlet-mapping> </web-app>
Note:
In the JSP file quickCarRentalView.jsp, the servlet is called using /. Conversely in the servlet source code, the JSP file is called using /view (see the example below):
...
publicvoid doWork(
...
RequestDispatcher dispatcher =
request.getRequestDispatcher("/view");
...The following lines are automatically added to the XML source:
<web-app> ... <ejb-local-ref> <description> </description> <ejb-ref-name>ejb/QuickOrderProcessorBean</ejb-ref-name> ... <ejb-link>QuickCarRentalEjb.jar#QuickOrderProcessorBean</ejb-link> </ejb-local-ref> </web-app>
Note:
In this case, the EJB name and the reference name match. If, however, the name of the session bean changes later, the corresponding bean call in the servlet source code can remain unchanged, provided you have used the reference name there.
You can find the reference name for the session bean in the corresponding line in the source code of QuickReservationServlet:
...
private QuickOrderProcessorLocal initializeController()
throws ServletException {
try {
Context ctx = new InitialContext();
QuickOrderProcessorLocalHome orderHome =
(QuickOrderProcessorLocalHome) ctx.lookup(
"java:comp/env/ejb/QuickOrderProcessorBean");
...You have entered all the necessary descriptions for this example application in the standard J2EE deployment descriptor web.xml.
In this case also, no J2EE Engine-specific entries are needed in the deployment descriptor web-j2ee-engine.xml. Thus, you have completely specified your Web Application project and can now continue by creating a corresponding archive file for the Web resources.