FileDocCategorySizeDatePackage
LoginServlet.javaAPI DocExample1467Thu Feb 12 15:33:56 GMT 2004com.jspservletcookbook

LoginServlet

public class LoginServlet extends HttpServlet

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

    
      WebCallbackHandler webcallback = new WebCallbackHandler(request);
      LoginContext lcontext = null;
      boolean loginSuccess = true;
    
    
      try{
    
          lcontext = new LoginContext( "WebLogin",webcallback );
          
          lcontext.login();
    
      } catch (LoginException lge){
    
          loginSuccess = false;
    
      }

          response.setContentType("text/html");
          java.io.PrintWriter out = response.getWriter();
          out.println("<html><head><title>Thanks for logging in</title></head><body>");
          out.println("<h2>Your logged in status</h2>");
      
          out.println(""+ ( loginSuccess ? "Logged in" : "Failed Login" ));
      
          out.println("</body></html>");
         
      
     
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

	   
	     doGet(request,response);