import java.io.*; import javax.servlet.http.*; import java.util.HashMap; /** * The Input servlet, queries the user for preferences and starts up the process by * which the student's transcript is retrieved from Banner. */ public class Input extends HttpServlet { private static final String PAGE_TITLE = "Input Page"; public void doGet(HttpServletRequest req, HttpServletResponse rsp) { PrintWriter out = null; try { rsp.setContentType("text/html"); out = rsp.getWriter(); HttpSession session = req.getSession(false); if(session == null) { HTMLUtils.printRedirectPage(out, "You must login to the system prior to viewing this page.", "Login"); return; } TranscriptRequest transReq = (TranscriptRequest) session.getAttribute("transcript_request"); if(transReq == null) { transReq = new TranscriptRequest(); session.setAttribute("transcript_request", transReq); } if(transReq.isStarted()) doPost(req, rsp); else HTMLUtils.printRedirectPage(out, "You must log in to the system prior to viewing this page.", "Login"); } catch(Exception e) { try { HTMLUtils.printException(out, e); } catch(Exception e2) {} } } public void doPost(HttpServletRequest req, HttpServletResponse rsp) { PrintWriter out = null; try { rsp.setContentType("text/html"); out = rsp.getWriter(); if(req.getCookies() == null) { HTMLUtils.printRedirectPage(out, "You must enable cookies in your browser before using the advisement system.", "Login"); return; } HttpSession session = req.getSession(false); if(session == null) { HTMLUtils.printRedirectPage(out, "You must login to the system prior to viewing this page.", "Login"); return; } TranscriptRequest treq = (TranscriptRequest) session.getAttribute("transcript_request"); if(treq == null) { treq = new TranscriptRequest(); session.setAttribute("transcript_request", treq); } if(!treq.isStarted()) { String userId, password; if((userId = req.getParameter("userid")) == null) { throw new FrontEndException( "Missing POST Data: userid"); } if((password = req.getParameter("password")) == null) { throw new FrontEndException( "Missing POST Data: password"); } String errorMsg; if((errorMsg = InputChecker.isLoginOk(userId, password)) != null) { HTMLUtils.printRedirectPage(out, errorMsg, "Login"); return; } treq.start(userId, password); } HTMLUtils.printHeader(out, PAGE_TITLE); out.println("
"); HashMap majors = RetrieverUtils.getMajors(); HashMap minors = RetrieverUtils.getMinors(); majors.put("Please make your selection", "none"); minors.put("Please make your selection", "none"); out.println("

"); HTMLUtils.printSelect(out, "Major", "major", majors, "Please make your selection"); majors.remove("Please make your selection"); majors.put("None", "no"); out.println("

"); HTMLUtils.printSelect(out, "Second Major", "secondmajor", majors, "None"); out.println("

"); HTMLUtils.printSelect(out, "Minor", "minor", minors, "Please make your selection"); out.println("

"); HTMLUtils.printTextBox(out, "text", "If you are a transfer student, how many CORE credits are you required to take?", "coreneeded", "(Leave blank if you don't know.)", null, null); out.println("

"); out.println(""); out.println("

"); HTMLUtils.printFooter(out); } catch(Exception e) { if(out != null) { try { HTMLUtils.printException(out, e); } catch(Exception e2) {} } } } }