IBM


4.8.9 Finding a URL for a servlet or JSP

The URL for a servlet or JSP is the path used to access it from a browser. The URL is partly defined in the deployment descriptor provided in the EAR file and partly defined in the deployment descriptor for the Web module containing the servlet or JSP.

To find the URL for a servlet or JSP:

1. Find the context root of the Web module containing the servlet.

2. Find the URL for the servlet.

3. Find the virtual host where the Web module is installed.

4. Find the aliases by which the virtual host is known.

5. Combine the virtual host alias, context root, and URL pattern to form the URL request of the servlet/JSP.

For example, to look up the URL for the snoop servlet:

1. Find the context root of the Web module DefaultWebApplication of the DefaultApplication enterprise application. This Web module contains the snoop servlet.

a. From the console navigation tree, select Applications  | Enterprise Applications.

b. Click the application that you are interested in, in our case, DefaultApplication.

c. On the Configuration tab, select Context Root for Web Modules. (Figure 4-40). You can see:

i. There is only one Web module in this application, DefaultWebApplication.

ii. The context root for the DefaultWebApplication Web module is "/".We will use this later.

Figure 4-40 Context root for the Web modules in DefaultApplication

d. Click OK to return to the DefaultApplication configuration.

2. Find the URL for the snoop servlet:

a. In the DefaultApplication configuration page, select Manage Modules.

b. Click the DefaultWebApplication Web module to see the general properties.

c. Click View Deployment Descriptor.

This displays the Web module properties window, as shown in Figure 4-41. Note that the URL pattern for the snoop servlet starting from the Web module context root is "/snoop/*". The Web module context root was "/".

Figure 4-41 DefaultWebApplication Web module deployment descriptor

d. Note that as you navigate through the windows, a navigation path is displayed below the Messages area. Click DefaultApplication to return to the application configuration page.

3. Find the virtual host where the DefaultWebApplication Web module is installed:

a. In the DefaultApplication configuration page, select Virtual hosts under Web Module Properties.

This will display all of the Web modules contained in the enterprise application, and the virtual hosts in which they have been installed. Note that the DefaultWebApplication Web module has been installed on the default_host virtual host.

Figure 4-42 List of virtual hosts

4. Find the host aliases for the default_host virtual host.

a. From the console navigation tree, select Environment  | Virtual Hosts.

b. Click default_host.

c. Select Host Aliases under Additional Properties.

This shows the list of aliases by which the default_host virtual host is known.

Figure 4-43 Default_host virtual host aliases

Note that the aliases are composed of a DNS host name and a port number. The host aliases for the default_host virtual host are *:80, *:9080 and *:9443, "*" meaning any host name.

5. Combine the virtual host alias, context root and URL pattern to form the URL request of the snoop servlet. Requests for the servlet with any of the following URLs will map to the default_host virtual host:

http://<hostname>:80/snoop

http://<hostname>:9080/snoop

https://<hostname>:9443/snoop



Redbooks ibm.com/redbooks

Next