Adding Descriptions to web.xml

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.



General Descriptions

Display Name

Returns a label for the War file to be created.


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


       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.



   <display-name> Rent-A-Car </display-name>

   <description> Web resources for car rental example. </description>





Defining a URL pattern

       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





The following entries are automatically added to the XML source:





       <servlet-name> QuickReservationServlet </servlet-name>

       <url-pattern> / </url-pattern>



       <servlet-name> quickCarRentalView.jsp </servlet-name>

       <url-pattern> /view </url-pattern>





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 =




Entering a local reference to an EJB

       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:







       <ejb-ref-name> ejb/QuickOrderProcessorBean </ejb-ref-name>


       <ejb-link> QuickCarRentalEjb.jar#QuickOrderProcessorBean </ejb-link>





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(




   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.

Next step:

Creating a War File