FileDocCategorySizeDatePackage
LogoutServlet.javaAPI DocExample1313Wed Oct 08 12:03:04 BST 2003com.jspservletcookbook

LogoutServlet

public class LogoutServlet extends HttpServlet

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

    
       HttpSession session = request.getSession();
       response.setContentType("text/html");
       java.io.PrintWriter out = response.getWriter();
       out.println("<html><head><title>Authenticated User Info</title></head><body>");
	   out.println("<h2>Logging out a user</h2>");
       out.println("request.getRemoteUser() returns: ");
       String remUser = request.getRemoteUser();
       out.println(remUser == null ? "Not authenticated." : remUser );
       out.println("<br>");
       out.println("request.isUserInRole(\"dbadmin\")  returns: ");
       boolean isInRole = request.isUserInRole("dbadmin");
       out.println(isInRole);
       out.println("<br>");
       //log out the user
       session.invalidate();
       out.println("</body></html>");
       out.close();
      
     
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

       
         doGet(request,response);