Facebook
From Tiny Pheasant, 9 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 196
  1.  
  2. package main.webapp.app.servlets;
  3. import javax.servlet.http.HttpServlet;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import javax.servlet.http.HttpSession;
  7. import java.io.IOException;
  8. import java.io.PrintWriter;
  9.  
  10.  
  11. public class LoginImpl extends HttpServlet {
  12.  
  13.     @Override
  14.     protected void doPost (HttpServletRequest request, HttpServletResponse response) throws IOException, NullPointerException {
  15.         //Sprawdza czy jestesmy juz zalogowani
  16.  
  17.  
  18.             response.setContentType("text/html; charset=utf-8");
  19.             PrintWriter out = response.getWriter();
  20.  
  21.  
  22.            // if (testLogin(request.getParameter("email"), request.getParameter("pwd"))) {
  23.  
  24.                 //request.setAttribute("trala", "abc");
  25.                 request.setAttribute("abc" ,"trala" );
  26.                 out.println(request.getAttribute("abc") + "aaa");
  27.  
  28.                 request.getSession().setAttribute("email", request.getParameter("email"));
  29.  
  30.                 out.println(request.getSession().getAttribute("email") + " a");
  31.                 out.println(request.getParameter("email"));
  32.                 out.println("<html>");
  33.                 out.println("<body>");
  34.                 out.println("<h1>Hello Servlet method post</h1>");
  35.                 out.println(request.getSession().getAttribute("email"));
  36.                 out.println(request.getSession().getAttribute("pwd"));
  37.         out.println("");
  38.                 out.println("</body>");
  39.                 out.println("</html>");
  40.                // response.sendRedirect("menu.jsp");
  41.            // } else {
  42.                 request.getSession().setAttribute("WypeĹ‚nij poprawnie formularz","message" );
  43.               //  response.sendRedirect("index.jsp");
  44.           // }
  45.  
  46.  
  47.  
  48.  
  49.         }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.    // private boolean testLogin (String login, String haslo){
  56.    //     if (login.equals("123")  && haslo.equals("123")  && !haslo.equals("") && !haslo.equals(""))
  57.    //         return true;
  58.    //     else return false;
  59.     //}
  60.  
  61. }
  62.