daily pastebin goal
33%
SHARE
TWEET

Untitled

a guest Jan 25th, 2016 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2. $("#bt").click(function(){
  3.     var user = $("#name").val();
  4.     var pass = $("#pass").val();
  5.     $.ajax({
  6.             url:"${pageContext.request.contextPath}/Authentication?user="+user+ "&pass="+pass ,
  7.             dataType: "json",
  8.             type:"POST",
  9.             success:function(result){
  10.                 if(result.abc != "Incorect"){
  11.                     window.location.href="${pageContext.request.contextPath} %>/jsp/mngCoffee.jsp";
  12.                 }
  13.                 else{
  14.                     alert(result.abc);
  15.                 }
  16.  
  17.             }});
  18. });
  19.    
  20. '<div>
  21.         <form action="<%=request.getContextPath() %>/Authentication" method="POST">
  22.             <fieldset>
  23.                 <legend>Login..</legend>
  24.                 <label for="name">Username :</label><br/>
  25.                 <input type="text" class="inputField"  id="name" name="txtName"/><br/>
  26.                 <label for="pass">Password :</label><br/>
  27.                 <input type="password" class="inputField" id="pass" name="txtPass"/></br>
  28.                 <button id="bt" type="button" >logon</button>
  29.  
  30.             </fieldset>
  31.         </form>
  32.  
  33. </div>'
  34.    
  35. PrintWriter out = response.getWriter();
  36.  
  37.     String ip = request.getRemoteAddr();
  38.     System.out.println(ip);
  39.  
  40.     String name = request.getParameter("user");
  41.     String pass = request.getParameter("pass");
  42.  
  43.     JSONObject o = new JSONObject();
  44.  
  45.     HttpSession session = request.getSession();
  46.     session.setMaxInactiveInterval(1800);
  47.  
  48.     String a =(String)session.getAttribute("name");
  49.     System.out.println(a);
  50.     if(a== null){
  51.  
  52.         RequestDispatcher dis = request.getRequestDispatcher("/jsp/login.jsp");
  53.         dis.forward(request, response);
  54.     }
  55.     else{
  56.         System.out.println(name);
  57.         RequestDispatcher dis = request.getRequestDispatcher("/jsp/mngCoffee.jsp");
  58.         dis.forward(request, response);
  59.     }
  60.     `
  61.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand