Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package com.nrc.protos.applicator.registration;
  7.  
  8. import java.io.DataInputStream;
  9. import java.io.IOException;
  10. import java.io.InputStream;
  11. import java.io.PrintWriter;
  12. import javax.servlet.ServletException;
  13. import javax.servlet.http.HttpServlet;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.servlet.http.HttpServletResponse;
  16.  
  17. /**
  18. *
  19. * @author mutahi
  20. */
  21. public class registration extends HttpServlet {
  22.  
  23. /**
  24. * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
  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. DataInputStream in=new DataInputStream((InputStream)request.getInputStream());
  34. PrintWriter out = response.getWriter();
  35.  
  36. String username = in.readUTF();
  37. String password = in.readUTF();
  38.  
  39. try {
  40. //TODO output your page here
  41. out.println("<html>");
  42. out.println("<head>");
  43. out.println("<title>Servlet registration</title>");
  44. out.println("</head>");
  45. out.println("<body>");
  46. out.println("<h1>Servlet registration at " + request.getContextPath () + "</h1>");
  47. out.println("</body>");
  48. out.println("</html>");
  49.  
  50. } finally {
  51. out.close();
  52. }
  53. }
  54.  
  55. // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  56. /**
  57. * Handles the HTTP <code>GET</code> method.
  58. * @param request servlet request
  59. * @param response servlet response
  60. * @throws ServletException if a servlet-specific error occurs
  61. * @throws IOException if an I/O error occurs
  62. */
  63. @Override
  64. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  65. throws ServletException, IOException {
  66. processRequest(request, response);
  67. }
  68.  
  69. /**
  70. * Handles the HTTP <code>POST</code> method.
  71. * @param request servlet request
  72. * @param response servlet response
  73. * @throws ServletException if a servlet-specific error occurs
  74. * @throws IOException if an I/O error occurs
  75. */
  76. @Override
  77. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  78. throws ServletException, IOException {
  79. processRequest(request, response);
  80. }
  81.  
  82. /**
  83. * Returns a short description of the servlet.
  84. * @return a String containing servlet description
  85. */
  86. @Override
  87. public String getServletInfo() {
  88. return "Short description";
  89. }// </editor-fold>
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement