Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.Statement;
- import javax.servlet.RequestDispatcher;
- import javax.servlet.ServletException;
- import javax.servlet.annotation.WebServlet;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.servlet.http.HttpSession;
- /**
- *
- * @author wrtrg1
- */
- @WebServlet(urlPatterns = {"/updateUserPendingComplaintList"})
- public class updateUserPendingComplaintList extends HttpServlet {
- //Database credentials:
- static final String urrrl = "jdbc:oracle:thin:@10.147.66.56:1521:XE";
- static final String USER = "SYSTEM";
- static final String PASS = "123456";
- /**
- * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
- * methods.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- protected void processRequest(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
- HttpSession session = request.getSession();
- RequestDispatcher rd;
- Connection conn = null;
- Statement stmt = null;
- ResultSet rs = null;
- /*
- Part 1: Making the query.
- Make the base queriy that includes the default condition for pending complaints
- Make use of request.getParameter to get the values of various HTML input fields from previous page form
- Use an if else ladder to make use of these input fields
- -If the fields are null do nothig and check the next field
- If the field is not null, add the "AND FIELDNAME="+fieldvariableontainingvalue string to the original query
- The above if else ladder should completey create your query as needed
- Step @: Getting the complaints in required list/set
- Run the query and that should return a result set
- Go through this result set in a while loop using rs.next()
- Store each of the required info in a ComplaintModel object, and on setting values for all fields, add the object to the pendingComplaintsList. Make sure you add them correctly along with the correct field names as used in the original code as those field names have beren used to print and identify the individual fields of each complaint
- After finishing creation of list you can then set it as request attribute along with the correct name and dispatch the request to the same calling jsp page
- */
- }
- // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
- /**
- * Handles the HTTP <code>GET</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Handles the HTTP <code>POST</code> method.
- *
- * @param request servlet request
- * @param response servlet response
- * @throws ServletException if a servlet-specific error occurs
- * @throws IOException if an I/O error occurs
- */
- @Override
- protected void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- processRequest(request, response);
- }
- /**
- * Returns a short description of the servlet.
- *
- * @return a String containing servlet description
- */
- @Override
- public String getServletInfo() {
- return "Short description";
- }// </editor-fold>
- }
Add Comment
Please, Sign In to add comment