SHARE
TWEET

Untitled

a guest Sep 11th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package br.com.lol;
  2.  
  3. import java.io.IOException;
  4. import java.io.PrintWriter;
  5. import javax.servlet.ServletException;
  6. import javax.servlet.annotation.WebServlet;
  7. import javax.servlet.http.HttpServlet;
  8. import javax.servlet.http.HttpServletRequest;
  9. import javax.servlet.http.HttpServletResponse;
  10.  
  11. /**
  12.  * Servlet implementation class MainServlet
  13.  */
  14. @WebServlet("/MainServlet")
  15. public class MainServlet extends HttpServlet {
  16.    
  17.     protected void processRequest(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {
  18.         response.setContentType("text/html;charset=UTF-8");
  19.        
  20.         String usuario = request.getParameter("usuario");
  21.         String senha = request.getParameter("senha");
  22.        
  23.         try (PrintWriter out = response.getWriter()) {
  24.             out.println("<!DOCTYPE html>");
  25.             out.println("<html lang=\"pt-br\">");
  26.             out.println("<head>");
  27.             out.println("<meta charset=\"UTF-8\">");
  28.             out.println("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">");
  29.             out.println("<title>Teste Web</title>");
  30.             out.println("</head>");
  31.             out.println("<body>");
  32.             out.println("<div style=\"text-align:center\">");
  33.             out.println("<h1>Bom dia "+usuario+"!</h1><br>");
  34.             out.println("</div>");
  35.             out.println("<form action=\"index.html\" method=\"POST\"></form>");
  36.             if ((usuario.equalsIgnoreCase("spielberg")) && (senha.equals("123456"))) {
  37.                 out.println("<h3>Você está cadastrado em nosso sistema.</h3><br>");
  38.             }
  39.             else {
  40.                 out.println("<h3>Você não está cadastrado em nosso sistema.</h3><br>");
  41.             }
  42.             out.println("<div style=\"text-align:center\">");
  43.             out.println("<input type\"submit\" value=\"Voltar\">");
  44.             out.println("</div>");
  45.             out.println("</body>");
  46.             out.println("</html>");
  47.         }
  48.     }
  49. }
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
 
Top