/*This servlet is to handle all user related queries. In the user's main page there would be different queries a user can do. On clicking any query, the control will shift to this servle. The query number (for our reference) will be passed with the URL. Depending upon this number different queries will be executed and the result will be shown to the user. */

import java.io.*;	
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.lang.*;
import java.util.*;
import java.util.Date;

public class UserQueryServlet extends HttpServlet
{ 
    public HttpSession session;  // session is availabe for the whole servlet
    
    public void doGet (HttpServletRequest request, 
		       HttpServletResponse response) 
	throws ServletException, IOException{
	PrintWriter out;
	ResultSet rs=null;
	String queryString, login;
	response.setContentType("text/html");
	out = response.getWriter();
	session = request.getSession(false);
	if (session!=null){
	    String queryNumberString = request.getParameter("queryNumber");
	    int queryNumber = (Integer.valueOf(queryNumberString)).intValue();
	    switch (queryNumber){
	    case 1:
		login=(String)session.getValue("userLogin");
		(SharedObjects.qe).userQueryOne(out, login);
		break;
	    case 2:
		login=(String)session.getValue("userLogin");
		(SharedObjects.qe).userQueryTwo(out, login);
		break;
	    case 3:
		login=(String)session.getValue("userLogin");
		(SharedObjects.qe).userQueryThree(out, login);
		break;
	    case 4:
		login=(String)session.getValue("userLogin");
		(SharedObjects.qe).userQueryFour(out, login);
		break;
	    case 5:
		login=(String)session.getValue("userLogin");
		(SharedObjects.qe).userQueryFive(out, login);
		break;
	    default:
		System.out.println("not a valid option");
	    }
	}
	else{
	    System.out.println("null session");
	}

	    
    }
}
