import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.util.*; import java.util.Date; import java.sql.Timestamp; import java.sql.*; import java.lang.System.*; public class StaffidServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out; response.setContentType("text/html"); out = response.getWriter(); out.println(""); /* This string parameters will capture information that is received from webpage and pass it through the array */ String [] staffinfo = request.getParameterValues("staff_id"); String firstStaffinfo = staffinfo [0]; Database2 db = new Database2(); String [] staffresults = db.selectWhere("*", "staffmembers", "staff_id= '"+ firstStaffinfo +"'"); String [] fileinfo = request.getParameterValues("frefcode"); String firstFileinfo = fileinfo [0]; String [] fileresults = db.selectWhere("*", "file", "frefcode= '"+ firstFileinfo +"'"); long currentTime = System.currentTimeMillis(); Timestamp ts = new Timestamp (currentTime); /* Insert into database*/ preparedStatement pstmt = db.preparedStatement( " INSERT INTO loan (staff_id, frefcode, datereturned) VALUES ( staff_id= ' + frefcode= ' + ts) "); out.println(ts); out.println("
"); out.println(""); out.println("Your details "); out.println("
"); out.println(""); out.println(pstmt); for (int num = 0; num < staffresults.length; num++) { out.println("
"); out.println(staffresults[num]); } for (int num = 0; num < fileresults.length; num++) { out.println("
"); out.println(fileresults[num]); } out.println("
"); out.println(""); out.close(); } }