FileDocCategorySizeDatePackage
ContextBinder.javaAPI DocExample921Fri Feb 13 07:43:42 GMT 2004com.jspservletcookbook

ContextBinder

public class ContextBinder extends HttpServlet

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

    
    //bind an object to the servlet context
    getServletContext().setAttribute(
	    "com.jspservletcookbook.ContextObject", new ContextObject());
    
    //better display something
      response.setContentType("text/html");
      java.io.PrintWriter out = response.getWriter();
      out.println("<html><head><title>Servlet Context Attribute</title></head><body>");
      out.println("<h2>Servlet Context Attribute Bound</h2>");
	  out.println("Object: " + getServletContext().getAttribute(
	    "com.jspservletcookbook.ContextObject"));
      out.println("</body></html>");