1 package edu.rice.rubis.beans.servlets; 2 3 import java.io.IOException ; 4 5 import javax.naming.Context ; 6 import javax.naming.InitialContext ; 7 import javax.servlet.ServletException ; 8 import javax.servlet.http.HttpServlet ; 9 import javax.servlet.http.HttpServletRequest ; 10 import javax.servlet.http.HttpServletResponse ; 11 12 17 public class SellItemForm extends HttpServlet 18 { 19 20 28 public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 29 { 30 doGet(request, response); 31 } 32 33 41 public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException , ServletException 42 { 43 ServletPrinter sp = null; 44 String categoryId=null, userId=null; 45 Context initialContext = null; 46 47 sp = new ServletPrinter(response, "SellItemForm"); 48 sp.printHTMLheader("RUBiS: Sell your item"); 49 50 try 51 { 52 initialContext = new InitialContext (); 53 } 54 catch (Exception e) 55 { 56 sp.printHTMLheader("RUBiS ERROR: SellItemForm"); 57 sp.printHTML("Cannot get initial context for JNDI: " +e+"<br>"); 58 sp.printHTMLfooter(); 59 return ; 60 } 61 62 categoryId = request.getParameter("category"); 63 userId = request.getParameter("user"); 64 if ((categoryId == null) || categoryId.equals("") || (userId == null) || userId.equals("")) 65 { 66 sp.printHTMLheader("RUBiS ERROR: SellItemForm"); 67 sp.printHTML("No category or user identifier received - Cannot process the request<br>"); 68 sp.printHTMLfooter(); 69 return ; 70 } 71 72 sp.printFile(Config.HTMLFilesPath+"/sellItemForm.html"); 73 sp.printHTML("<input type=hidden name=\"userId\" value=\""+userId+"\"> "); 74 sp.printHTML("<input type=hidden name=\"categoryId\" value=\""+categoryId+"\"> "); 75 sp.printHTMLfooter(); 76 } 77 } 78 | Popular Tags |