配置页面列表 Servlet 客户机配置
您可在 IBM® Web 扩展文件中定义 PageListServlet 配置信息。使用组装工具创建 IBM Web 扩展文件并存储在 Web 应用程序归档 (WAR) 文件中。
关于此任务
注意: 在 WebSphere® Application Server V9.0 中不推荐使用 PageList Servlet 定制扩展,在以后的发行版本中将移除该功能。重新设计旧应用程序以使用 javax.Servlet.filter 类而不使用 com.ibm.Servlet 类。从 Servlet 2.3 规范开始,javax.Servlet.filter 类使您可以拦截请求和检查响应。还可以使用 javax.Servlet.filter 类来实现链接功能,以及修饰或截断响应。
要配置和实现页列表:
过程
扩展 PageListServlet
以下示例显示 Servlet 如何扩展 PageListServlet 类和确定客户机必需的标记语言类型。然后 Servlet 使用 callPage 方法调用适当的 JavaServer Pages (JSP) 文件。在本示例中,为响应提供正确标记语言的 JSP 文件是 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);
}
}
}