Advertisement
Arcthurus

SolicitacaoMatriculaVersionControl

Sep 12th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 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 web;
  7.  
  8. import java.io.IOException;
  9. import java.io.PrintWriter;
  10. import java.util.ArrayList;
  11. import java.util.Enumeration;
  12. import javax.servlet.ServletException;
  13. import javax.servlet.annotation.WebServlet;
  14. import javax.servlet.http.HttpServlet;
  15. import javax.servlet.http.HttpServletRequest;
  16. import javax.servlet.http.HttpServletResponse;
  17. import javax.servlet.http.HttpSession;
  18.  
  19. /**
  20. *
  21. * @author user
  22. */
  23. @WebServlet(name = "SolicitacaoMatricula", urlPatterns = {"/SolicitacaoMatricula"})
  24. public class SolicitacaoMatricula extends HttpServlet {
  25.  
  26. /**
  27. * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
  28. * methods.
  29. *
  30. * @param request servlet request
  31. * @param response servlet response
  32. * @throws ServletException if a servlet-specific error occurs
  33. * @throws IOException if an I/O error occurs
  34. */
  35. protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  36. throws ServletException, IOException {
  37. response.setContentType("text/html;charset=UTF-8");
  38. String str="";
  39. Enumeration<String> campos = request.getParameterNames();
  40. HttpSession session = request.getSession();
  41. ArrayList<Turma> lista = (ArrayList<Turma>)session.getAttribute("list");
  42. ArrayList<String> aluno = (ArrayList<String>)session.getAttribute("aluno");
  43. ArrayList<Turma> listaAux = new ArrayList<>();
  44. int i = 0;
  45. for (Enumeration<String> e = campos; e.hasMoreElements();){
  46. str = (String)e.nextElement();
  47. for (Turma tur: lista){
  48. String ok = request.getParameter("checkbox[" + i + "]");
  49. if (ok != null){
  50. listaAux.add(tur);
  51. }
  52. i++;
  53. }
  54. }
  55. lista.clear();
  56. try (PrintWriter out = response.getWriter()) {
  57. out.println("<!DOCTYPE html>");
  58. out.println("<html>");
  59. out.println("<head>");
  60. out.println("<title>Solicitacao de Matricula</title>");
  61. out.println( "<link href=\"css/style.css\" rel=\"stylesheet\" type=\"text/css\"/>");
  62. out.print("<link rel=\"stylesheet\" href=\"styleTable.css\" type=\"text/css\">");
  63. out.println("<style type=\"text/css\">" +
  64. "<!-- " +
  65. "body {background-image:url(http://eppora.com/wp-content/uploads/2015/05/plain-light-color-for-guest-background.jpg);"
  66. + "background-repeat: no-repeat; background-size: cover;"
  67. + " color:black; font-size:150%}"+
  68.  
  69. "//--></style>");
  70. out.println("</head>");
  71. out.println("<body>");
  72. /*out.println("<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Antu_task-complete.svg/2000px-Antu_task-complete.svg.png\" "
  73. + "style=\"width:50px;height:60px;\" class=\"center-block img-responsive foto\" align=\"left\">"
  74. + "<center><h4>Operação bem-sucedida!</h4><center>");*/
  75. out.println("<table align=\"center\"><tr><td>");
  76. out.println("<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Antu_task-complete.svg/2000px-Antu_task-complete.svg.png\" "
  77. + "style=\"width:50px;height:60px;\"");
  78. out.println("</td><td valign=\"middle\">Operação bem-sucedida!</td></tr></table>");
  79.  
  80. out.println("<center><h2>Seus Dados:</h2></center><br/>");
  81. out.println("<div align=\"center\"><h4>");
  82. out.println("<b>Aluno: "+aluno.get(1)+"</b><br/>");
  83. out.println("<b>Matrícula: "+aluno.get(0)+"</b><br/>");
  84. out.println("<b>Codigo do Curso: "+aluno.get(2)+"</b><br/>");
  85. out.println("</h4></div>");
  86.  
  87. out.println("<center><br><h2>Disciplinas Solicitadas</h2></center>");
  88. out.println("<table align=\"center\" class = \"table table-bordered\"><tr>");
  89. out.println("<th><b>Código da disciplina</b></th>"
  90. +"<th><b>Nome da disciplina</b></th>"
  91. +"<th><b>Carga horária semanal</b></th>"
  92. +"<th><b>Código da turma</b></th>"
  93. +"<th><b>Horários da turma</b></th></tr>");
  94. for (Turma tur: listaAux){
  95. out.println("<tr><td>"+ tur.getDiscCod() + "</td>"
  96. + "<td>"+tur.getDiscNome()+ "</td>"
  97. + "<td>"+tur.getDiscCarga()+ "</td>"
  98. + "<td>"+tur.getTurmaCod()+ "</td>"
  99. + "<td>"+tur.getTurmaHoras()+ "</td></tr><br/>");
  100. }
  101. out.println("</table>");
  102. out.println("</body>");
  103. out.println("</html>");
  104. }
  105. }
  106.  
  107. // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
  108. /**
  109. * Handles the HTTP <code>GET</code> method.
  110. *
  111. * @param request servlet request
  112. * @param response servlet response
  113. * @throws ServletException if a servlet-specific error occurs
  114. * @throws IOException if an I/O error occurs
  115. */
  116. @Override
  117. protected void doGet(HttpServletRequest request, HttpServletResponse response)
  118. throws ServletException, IOException {
  119. processRequest(request, response);
  120. }
  121.  
  122. /**
  123. * Handles the HTTP <code>POST</code> method.
  124. *
  125. * @param request servlet request
  126. * @param response servlet response
  127. * @throws ServletException if a servlet-specific error occurs
  128. * @throws IOException if an I/O error occurs
  129. */
  130. @Override
  131. protected void doPost(HttpServletRequest request, HttpServletResponse response)
  132. throws ServletException, IOException {
  133. processRequest(request, response);
  134. }
  135.  
  136. /**
  137. * Returns a short description of the servlet.
  138. *
  139. * @return a String containing servlet description
  140. */
  141. @Override
  142. public String getServletInfo() {
  143. return "Short description";
  144. }// </editor-fold>
  145.  
  146. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement