FileDocCategorySizeDatePackage
ChatServlet.javaAPI DocExample3304Sun Feb 08 21:34:02 GMT 2004darwinsys.chat

ChatServlet

public class ChatServlet extends HttpServlet implements ChatConstants

Fields Summary
Constructors Summary
Methods Summary
public voiddoPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Called in response to a GET request (data encoded in the URL)


		ServletContext application = getServletContext();

		ChatState chat = (ChatState)application.getAttribute(APP_STATE);
		// assert(chat != null);

		// to do: logic code and main HTML goes HERE.
		String iSay = request.getParameter("iSay");
		if (iSay != null) {
			iSay = iSay.trim();
			if (iSay.length() != 0) {
				synchronized(chat) {
					chat.chat.add(iSay);
					chat.last++;
				}
			}
		}

		// Output section in MVC: dispatch to JSP to display the work.
		// (Remember the URL for an RD **MUST** be absolute).
		RequestDispatcher rd = application.getRequestDispatcher("/chat.jsp");
		rd.forward(request, response);
		/*NOTREACHED*/