Set page list servlet client configurations


 

+

Search Tips   |   Advanced Search

 

We can define PageListServlet configuration information in the IBM Web Extensions file, which is stored in the WAR file by an assembly tool.

The PageList Servlet custom extension is deprecated in WAS V7.0 and will be removed in a future release. Re-architect the legacy applications to use...

javax.servlet.filter

...instead of...

com.ibm.servlet

Starting from the Servlet 2.3 specification, javax.servlet.filter classes we can intercept requests and examine responses. We can also use javax.servlet.filter classes to achieve chaining functionality, as well as embellishing or truncating responses.

To configure and implement page lists:

  1. To configure page list information, use the Add Markup Language entry dialog of an assembly tool. On the Servlets tab of a Web deployment descriptor editor, select a servlet and click Add under WebSphere Extensions.

  2. Add the callPage() method to the servlet to invoke a JSP file in response to a client request.

    The PageListServlet has a callPage() method that invokes a JSP file in response to the HTTP request for a page in a page list. The callPage() method can be invoked in one of the following ways:

    • callPage(String pageName, HttpServletRequest request, HttpServletResponse response)

      ...where the method arguments are...

      pageName

      A page name defined in the PageListServlet configuration

      request

      The HttpServletRequest object

      response

      The HttpServletResponse object

    • callPage(String mlName, String pageName, HttpServletRequest request, HttpServletResponse response)

      where the method arguments are:

      mlName

      A markup language type

      pageName

      A page name defined in the PageListServlet configuration

      request

      The HttpServletRequest object

      response

      The HttpServletResponse object

  3. Use the PageList Servlet client type detection support to determine the markup language type a calling client requires for the response.

 

Example

The following example shows how a servlet extends the PageListServlet class and determines the markup-language type required by the client. The servlet then uses the callPage method to call an appropriate JSP file. In this example, the JSP file that provides the correct markup-language for the response is Hello.page.

 public class HelloPervasiveServlet extends PageListServlet implements Serializable
{
     /*
     * doGet -- Process incoming HTTP GET requests
     */
    public  void doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    {
       
// This is the name of the page to be called:
       String pageName = "Hello.page";
 
       
// First check if the servlet was invoked with a queryString that contains 
      
// a markup-language value.
       
// For example, if this is how the  servlet is invoked:
       
//  http://localhost/servlets/HeloPervasive?mlname=VXML
       
//  then use the following method:
       String mlname= getMLNameFromRequest(request);

        
// If no markup language type is provided in the queryString, 
        
// then try to determine the client
        
// Type from the request, and use the markup-language name configured in 
        
// the client_types.xml file.   

        if (mlName == null)
        {
          mlName = getMLTypeFromRequest(request);
         }
         try
         {
           
// Serve the request page.
           callPage(mlName, pageName, request, response);
          }
          catch (Exception e)
          { 
            handleError(mlName, request, response, e);
           }
       }
}

 

Related tasks

Assembling applications
Page lists
Client type detection support
client_types.xml

 

Related

Web apps: Links