String servletPath = request.getServletPath();
HttpSession session = request.getSession();
if(servletPath.equals("/auctions/bid")) {
User u = (User) session.getAttribute("user");
String bid = request.getParameter("bid");
Integer id = new Integer(request.getParameter("id"));
Auction a = Auction.getById(id);
a.setLastPrice(new Float(bid));
a.setLastUserId(u.getId());
a.update();
response.sendRedirect(request.getContextPath());
}
else if(servletPath.equals("/auctions/save"))
{
User u = (User) session.getAttribute("user");
Auction auction = new Auction();
MultipartRequest multi = new MultipartRequest(request, "/home/buzz/NetBeansProjects/bweb/web/images/");
auction.setProduct(multi.getParameter("newProduct"));
auction.setCatId(new Integer(multi.getParameter("newCat")));
File f = multi.getFile("newImage");
String fileName = multi.getFilesystemName("newImage");
auction.setPhoto(fileName);
auction.setStartingPrice(new Float (multi.getParameter("newStartingPrice")));
auction.setLastPrice(new Float (multi.getParameter("newStartingPrice")));
auction.setMinPrice( new Float (multi.getParameter("newMinPrice")));
Integer duration,i = new Integer(multi.getParameter("newDuration"));
if(i == 1) duration = 4;
else if(i == 2) duration = 6;
else duration = 10;
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, duration );
Long e = (cal.getTimeInMillis());
java.sql.Date expire = new java.sql.Date(e);
auction.setExpire(expire);
auction.setShipping(multi.getParameter("newShip"));
auction.setUserId(u.getId());
auction.setLastPrice(null);
auction.setLastUserId(null);
auction.setDescription(multi.getParameter("newDesc"));
auction.save();