FileDocCategorySizeDatePackage
FilterServlet.javaAPI DocGlassfish v2 API3607Mon Oct 17 14:54:24 BST 2005demo

FilterServlet

public class FilterServlet extends HttpServlet
This servlet is used to determine whether the user is logged in before forwarding the request to the selected URL.

Fields Summary
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
This method handles the GET requests from the client.

      
        // check to be sure we're still logged in 
        // before forwarding the request.
        HttpSession session = request.getSession();
        MailUserBean mailuser = (MailUserBean)session.getAttribute("mailuser");
        String servletPath = request.getServletPath();
        servletPath = servletPath.concat(".jsp");
        
        if (mailuser.isLoggedIn())
            getServletConfig().getServletContext().
                getRequestDispatcher("/" + servletPath).
                forward(request, response);
        else
            getServletConfig().getServletContext().
                getRequestDispatcher("/index.html").
                forward(request, response);
    
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
This method handles the "POST" submission from two forms: the login form and the message compose form.


        String servletPath = request.getServletPath();
        servletPath = servletPath.concat(".jsp");
        
        getServletConfig().getServletContext().
            getRequestDispatcher("/" + servletPath).forward(request, response);