public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
	{
		super.initInstance(req, res);
		User u = super.storeUser();

		Market m = (Market) (req.getAttribute("marketBean"));

		boolean opposite = false;
		int marketId = 0;
		Boolean winner = null;

		try {opposite = Boolean.parseBoolean(escapeChars(req.getParameter("opposite")));}
		catch (Exception e) {}

		try {marketId = Integer.parseInt(escapeChars(req.getParameter("id")));}
		catch (Exception e) {}

		try
		{
			String requestWinner = escapeChars(req.getParameter("winner"));
			winner = (requestWinner == null || requestWinner.equals("") ? null : Boolean.valueOf(requestWinner));
		}
		catch (Exception e) {}

		if (m == null)
			m = new Market();

		marketDao.getMarket(marketId, m);

		if (winner != null)
		{
			marketDao.closeMarket(marketId, (boolean) winner);
			super.forward("index");
		}
		else
		{
			ArrayList<Sell> asks = marketDao.getAsks(marketId, opposite);
			ArrayList<Sell> bids = marketDao.getBids(marketId, opposite);
			String logData = marketDao.getLogData(marketId);
			boolean[] b = marketDao.hasEndedAndMustBeConfirmed(m.getMarketId(), u.getId());

			req.setAttribute("hasEnded", b[0]);
			req.setAttribute("mustBeConfirmed", b[1]);
			req.setAttribute("logData", logData);
			req.setAttribute("marketBean", m);
			req.setAttribute("marketId", marketId);
			req.setAttribute("opposite", opposite);
			req.setAttribute("asks", asks);
			req.setAttribute("bids", bids);

			//out.println("###### MARKET_ID ##########" + req.getAttribute("marketId"));
			super.forward("market.jsp");
		}
	}