// import SharedObjects;
// import UserObject;
// import AuctionQueryHandler;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class PlaceAuctionServlet extends HttpServlet
{
	 //AuctionQueryHandler SharedObjects.aqh = new AuctionQueryHandler();

	 public void doGet (HttpServletRequest request, HttpServletResponse response)
		  throws ServletException, IOException
		  {			   
			   System.out.println("in do get ");

			   HttpSession hs = request.getSession(false);

			   if(hs !=  null)
			   {
					System.out.println("login of sesion= " + (String)hs.getValue("userLogin"));
			   }
			   else
			   {
					System.out.println("----------no session --------------------");
			   }
			   
			   //UserObject uso = new UserObject("aranjan", "aranjan");
			   //hs.putValue("userObj", uso);

			   //System.out.println("login of sesion= " + ((UserObject)hs.getValue("userObj")).getLogin());
			   
			   PrintWriter out = response.getWriter();
			   response.setContentType("text/html");
			   System.out.println("in do get: at 1 ");
			  
			   String param = (String)request.getAttribute("category");
			  // String param = request.getParameter("category");
			   System.out.println("category= " + param);
			   //System.out.println("category= " + request.getParameter("category"));

			   SharedObjects.qe.handleSellFormDisplay(out, param);
			   //SharedObjects.aqh.handleSellFormDisplay(out, request.getParameter("category"));
			   
			   System.out.println("in do get: at 2 ");
			   //SharedObjects.aqh.closeConn();
			   //out.close();
			   System.out.println("in do get:done ");
		  }

	 //-----------------------------------------------------------------------------
	 public void doPost(HttpServletRequest request,HttpServletResponse response) 
		  throws ServletException, IOException
		  {
			   System.out.println("in do post ");
			   HttpSession hs = request.getSession(false);
			   response.setContentType("text/html");
			   PrintWriter  out;			   
			   out = response.getWriter();

			   String l = request.getParameter("Login");
			   String p = request.getParameter("Password");
			   
			   System.out.println("l/p sent= " + l + p);
			  
			   if((hs == null) && (SharedObjects.qe.checkLoginPasswd(l,p)))
			   {
					hs = request.getSession(true);	
					//UserObject uo = new UserObject(l,p);
					hs.putValue("userLogin", l);
					hs.putValue("password", p);
			   }
			 
			   
			   System.out.println("hs not null or login wrong");
			   //System.out.println("login of sesion= " + ((UserObject)hso.getValue("user")).getLogin());
			   
			   
			   SharedObjects.qe.handleAuctionConfirmation(out, request);
			   //SharedObjects.aqh.closeConn();
			   //out.close();
		  }
}






