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. |
...
1. Double-click the web.xml node of the QuickCarRentalWeb project structure.
The Developer Studio opens a multipage editor, which allows you to enter descriptions in the standard deployment descriptor web.xml.
2. On the General tab, enter in the Display Name field the name Rent-A-Car, along with a short text in Description – such as Web resources for Car Rental example.
|
|
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>
|
3. Choose the Mapping tab.
4. Select Servlet Mappings and choose Add.
5. In the list that appears, select the two entries QuickReservationServlet andquickCarRentalView.jsp and confirm by choosing OK.
6. Assign the URL Pattern to each Web resource as follows:
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):
... public void doWork( ... RequestDispatcher dispatcher = request.getRequestDispatcher("/view"); ...
|
7. Choose the EJBs tab.
8. In the EJB Local References frame, choose Add.
9. From the selection list that appears, choose QuickOrderProcessorBean and confirm using OK.
|
|
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"); ...
|
10. Save your changes to the deployment descriptor entries by choosing the appropriate icon in the toolbar.
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.