Network Deployment (Distributed operating systems), v8.0 > Develop and deploying applications > Develop web applications > Develop web applications > Develop servlets > Develop servlets with WAS extensions


Configure page list servlet client configurations

We can define PageListServlet configuration information in the IBM Web Extensions file. The IBM Web Extensions file is created and stored in the web applications archive (WAR) file by an assembly tool.

Attention: The PageList Servlet custom extension is deprecated in WAS v8.0 and will be removed in a future release. Re-architect your legacy applications to use javax.servlet.filter classes instead of com.ibm.servlet classes. Starting from the Servlet 2.3 specification, javax.servlet.filter classes you 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:


Procedure

  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 your servlet to invoke a JavaServer Page (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


Page lists
Client type detection support
client_types.xml
Assembling applications


Related


Web applications: Resources for learning

+

Search Tips   |   Advanced Search