InfoCenter Home >
4: Developing applications >
4.2: Building Web applications >
4.2.1: Developing servlets >
4.2.1.3: Servlet content, examples, and samples >
4.2.1.3.9: PageListServlet support

4.2.1.3.9: PageListServlet support

IBM WebSphere Application Server supplies the PageListServlet to call a Java Server Page (JSP) by name. The PageListServlet uses configuration information to map a JSP name to the URI, where the URI specifies a JSP file in the WAR module. This support allows application developers to stop hard-coding URLs in their servlets.

These mappings, or page lists, are logically grouped according to the markup-language type (HTML, WML, and others) the JSP file is going to return to the requesting client. This allows applications, through the use of servlets that extend the PageListServlet class, to call a JSP file that returns the proper markup-language data type of the calling client. For example, if a request comes from a PDA, which requires WML data, and makes a request to a servlet that extends the PageListServlet, then a Java Server Page that returns WML data is called.

PageListServlet configuration information can be defined either in the IBM Web Extensions file or in an XML servlet configuration file. The IBM Web Extensions file is created and stored in the WAR file by the IBM WebSphere Application Assembly Tool. An XML servlet configuration file can be created using IBM WebSphere Studio or manually.

The PageListServlet has a callPage() method that invokes a Java Server Page in response to an HTTP request for a page in a page list.

The callPage() method can be invoked as follows:

  1. callPage(String pageName, HttpServletRequest request, HttpServletResponse response)
    • pageName - A page name defined in the PageListServlet configuration
    • request - The HttpServletRequest object
    • response - The HttpServletResponse object

       For this method of invocation, the default markup-language is HTML.
  2. callPage(String mlName, String pageName, HttpServletRequest req, HttpServletResponse resp)
    • mlName - A markup-language type.
    • pageName - A page name defined in the PageListServlet configuration
    • request - The HttpServletRequest object
    • response - The HttpServletResponse object

See the Javadoc for the PageListServlet for a complete list of available APIs.

In addition to providing the page list mapping capability, the PageListServlet also has Client Type Detection support. Using the configuration information in the client_types.xml file, a servlet can determine the markup-language type the calling client requires for the response. This support allows the user's servlet to call an appropriate JSP, based on markup-language type. Use the second version of the callPage() method (described above) for Client Type Detection support.

In structuring the servlet code, keep in mind that the PageListServlet.callPage() method is not an exit. Any servlet code that follows this method call will be executed.

Go to previous article: Obtaining the Web application classpath from within a servlet Go to next article: Extending PageListServlet

 

 
Go to previous article: Obtaining the Web application classpath from within a servlet Go to next article: Extending PageListServlet