/** * This class is used to display all database tables to the * user in the form of an HTML form drop-down (select) field, so that the * user can choose which one they want to administer. It also displays a * drop down box that asks the user to select which catalog they want to use * and several radio buttons to choose which operation they want to perform */ package admin; import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; import utilities.*; public class PresentMenu extends HttpServlet { /** * if an error occurs such as not logged in redirect to this error page for now set for the login page */ private String errorTarget = "../admin/index.jsp"; /** * used to initialize the servlet */ public void init(ServletConfig config) throws ServletException { super.init(config); } /** * all get requests are forwarded to doPost() */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // If it is a get request forward to doPost() doPost(request, response); } /** * This method does all the work */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Connection conn=null; ResultSet tableSet=null; //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 + "

"); String html="

"); out.println("

Please select what information you would like to administer:
"); html= html + "

"; html = html + "View    "; html = html + "Add    "; html = html + "Modify    "; html = html + "Delete    "; html = html + "

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