/* Code by George Kichukov for SAS 11/17/2002 * This class is used to modify requriements + pre/co requisites */ package admin; import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import utilities.*; public class ModifyReq extends HttpServlet { private String errorTarget = "../admin/index.jsp"; public void init(ServletConfig config) throws ServletException { super.init(config); } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // If it is a get request forward to doPost() doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //name of the user String name=""; PrintWriter out = response.getWriter(); response.setContentType("text/html"); //first thing that every servlet or jsp should do is check if user is logged in HttpSession session = request.getSession(false); //if not logged in redirect to login if(session == null) { HTMLUtils.printRedirectPage(out, "You must login to the system prior to viewing this page.", errorTarget); return; } //else if logged in take the name from the session else { name=(String)session.getAttribute("user"); //if the name is null if(name == null) { HTMLUtils.printRedirectPage(out, "You must login to the system prior to viewing this page.", errorTarget); return; } } //second output the Admin Header HTMLUtils.printAdminHeader(out); //display welcome message to the user out.println("

Welcome " + name + "

"); //get the parameters String id = request.getParameter("id"); //if this is for specific major or minor String mID = request.getParameter("mID"); String oper = request.getParameter("oper"); String table = request.getParameter("table"); //first get exact field that we want to modify String field1 = request.getParameter("field"); out.println(""); out.println(""); out.println(""); out.println(""); out.println(""); TableLayout layout = new TableLayout(out); //if the table is COURSES this means //we want to add/modify prereq, coreq or any other list if(table.equals("COURSES")) { //set up the form to go to QueryList out.println("
"); //include required fields needed for processing out.println(""); out.println(""); out.println(""); out.println(""); if(oper.equals("Add")) { //display textbox for requirement description out.println("
Please enter list: "); }//end if Add if(oper.equals("Modify")) { try { ResultSet rs1=Retriever.executeSQL("select " + field1 + " from COURSES where CourseID=" + id); rs1.next(); String req=rs1.getString(1); if(!req.equals("none")) { //parse the requirment string req=RequirementParser.toCourseDisplayString(rs1.getString(1)); } //display textbox for requirement description out.println("
Please Enter List: "); } catch(SQLException e){out.println("SQLException " + e.getMessage());} }//end if Modify }//end if course else { field1="CourseList"; //set up the form out.println(""); //include required fields needed for processing out.println(""); out.println(""); out.println(""); out.println(""); //if the operation is Modify //prepopulate the form fields if(oper.equals("Modify")) { try { ResultSet rs1=Retriever.executeSQL("select * from " + table + " where ID=" + id); rs1.next(); layout.beginTable(); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println("Credits:"); layout.spaceCell(15); layout.formCell(TableLayout.ALIGN_LEFT); out.println(""); //parse the requirment string String req=RequirementParser.toCourseDisplayString(rs1.getString(3)); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println("From:"); layout.spaceCell(15); layout.formCell(TableLayout.ALIGN_LEFT); out.println(""); layout.endTable(); } catch(SQLException e){out.println("SQLException " + e.getMessage());} } //end if Modify //if the operation is Add //display empty form fields if(oper.equals("Add")) { layout.beginTable(); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println("Credits:"); layout.spaceCell(15); layout.formCell(TableLayout.ALIGN_LEFT); //display textbox for number of credits out.println(""); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println("From:"); layout.spaceCell(15); layout.formCell(TableLayout.ALIGN_LEFT); //display textbox for requirement description out.println(""); layout.endTable(); }//end if Add }//end else out.println("
"); layout.beginTable(); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println(""); layout.formCell(TableLayout.ALIGN_RIGHT); out.println(""); layout.spaceCell(10); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.spaceCell(20); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.spaceCell(5); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println(""); layout.formCell(TableLayout.ALIGN_RIGHT); out.println(""); layout.spaceCell(10); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.spaceCell(20); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.spaceCell(5); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.row(); layout.spaceCell(0); layout.spaceCell(0); layout.spaceCell(0); layout.spaceCell(0); layout.spaceCell(0); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.spaceCell(5); layout.formCell(TableLayout.ALIGN_RIGHT); out.println("
"); layout.row(); layout.formCell(TableLayout.ALIGN_LEFT); out.println("
"); layout.formCell(TableLayout.ALIGN_LEFT); out.println("
"); layout.endTable(); out.println("


"); out.println("

"); out.println(""); HTMLUtils.printAdminFooter(out); } }