01: package org.claros.chat.ajax;
02:
03: import java.io.IOException;
04: import java.io.PrintWriter;
05:
06: import javax.servlet.ServletException;
07: import javax.servlet.http.HttpServlet;
08: import javax.servlet.http.HttpServletRequest;
09: import javax.servlet.http.HttpServletResponse;
10:
11: import org.claros.chat.controllers.QueueController;
12:
13: public class MarkAsReadService extends HttpServlet {
14:
15: /**
16: *
17: */
18: private static final long serialVersionUID = -1655612292561309429L;
19:
20: /**
21: * The doPost method of the servlet. <br>
22: *
23: * This method is called when a form has its tag value method equals to post.
24: *
25: * @param request the request send by the client to the server
26: * @param response the response send by the server to the client
27: * @throws ServletException if an error occurred
28: * @throws IOException if an error occurred
29: */
30: public void doPost(HttpServletRequest request,
31: HttpServletResponse response) throws ServletException,
32: IOException {
33:
34: response.setHeader("Expires", "-1");
35: response.setHeader("Pragma", "no-cache");
36: response.setHeader("Cache-control", "no-cache");
37: response.setHeader("Content-Type", "text/xml; charset=utf-8");
38: PrintWriter out = response.getWriter();
39:
40: try {
41: String user = (String) request.getSession().getAttribute(
42: "user");
43: String sId = (String) request.getParameter("id");
44:
45: String dd = (String) request.getSession().getAttribute(
46: "defaultDomain");
47: QueueController.setDelivered(user, new Long(sId), dd);
48: out.print("ok");
49: } catch (Exception e) {
50: out.print("fail");
51: }
52: }
53:
54: }
|