Advertisement
Guest User

wetd

a guest
Dec 9th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package com.myapp.struts;
  7.  
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10. import javax.servlet.ServletException;
  11. import javax.servlet.http.HttpServlet;
  12. import javax.servlet.http.HttpServletRequest;
  13. import javax.servlet.http.HttpServletResponse;
  14.  
  15. /**
  16. *
  17. * @author chpstudent
  18. */
  19. public class checkLogin extends HttpServlet {
  20.  
  21. /**
  22. * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
  23. * methods.
  24. *
  25. * @param request servlet request
  26. * @param response servlet response
  27. * @throws ServletException if a servlet-specific error occurs
  28. * @throws IOException if an I/O error occurs
  29. */
  30. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  31. throws ServletException, IOException {
  32. response.setContentType("text/html;charset=UTF-8");
  33. String url="jdbc:derby://localhost:1527/";
  34. String dbName="SB2018";
  35. String user="app";
  36. String password="app";
  37. try (PrintWriter out = response.getWriter()) {
  38. /* TODO output your page here. You may use following sample code. */
  39. out.println("<!DOCTYPE html>");
  40. out.println("<html>");
  41. out.println("<head>");
  42. out.println("<title>Servlet checkLogin</title>");
  43. out.println("</head>");
  44. out.println("<body>");
  45. out.println("<h1>Servlet checkLogin at " + request.getContextPath() + "</h1>");
  46. out.println("</body>");
  47. out.println("</html>");
  48. }
  49. }
  50.  
  51. // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  52. /**
  53. * Handles the HTTP <code>GET</code> method.
  54. *
  55. * @param request servlet request
  56. * @param response servlet response
  57. * @throws ServletException if a servlet-specific error occurs
  58. * @throws IOException if an I/O error occurs
  59. */
  60. @Override
  61. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  62. throws ServletException, IOException {
  63. processRequest(request, response);
  64. }
  65.  
  66. /**
  67. * Handles the HTTP <code>POST</code> method.
  68. *
  69. * @param request servlet request
  70. * @param response servlet response
  71. * @throws ServletException if a servlet-specific error occurs
  72. * @throws IOException if an I/O error occurs
  73. */
  74. @Override
  75. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  76. throws ServletException, IOException {
  77. processRequest(request, response);
  78. }
  79.  
  80. /**
  81. * Returns a short description of the servlet.
  82. *
  83. * @return a String containing servlet description
  84. */
  85. @Override
  86. public String getServletInfo() {
  87. return "Short description";
  88. }// </editor-fold>
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement