tags:

views:

57

answers:

1

Hi i'm new to Task queue java API i tried a simple Example for it. My idea is to redirect the queue file to a servlet and to print some statement in the servlet.But it doesn't work. i mapped web.xml and used default queue I didnt get any Error but the file is not redirected to servlet . this is the codee i followed

taskq.java
           public class taskq extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)throwsIOException {


    Queue queue = QueueFactory.getDefaultQueue();

    System.out.println("taskqueue");
    queue.add(url("/worker"));

}
    worker.java
         public class worker extends HttpServlet {

private static final long serialVersionUID = 1L;
public String s;

public void doGet(HttpServletRequest req, HttpServletResponse resp)throws IOException {
    String s="crimsom";
    System.out.println(s);
}

 }

Please Help me on this issue. Regards Sharun.

+1  A: 

You should add your output to the servlet response, instead of System.out:

public void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
    Queue queue = QueueFactory.getDefaultQueue();

    resp.setContentType("text/html");
    PrintWriter out = resp.getWriter();

    out.println("<html>");
    out.println("<head><title>Hello world</title></head>");
    out.println("<body><h1>taskqueue</h1></body></html>");

    queue.add(url("/worker"));
}
Péter Török
The code i followed is right? Just for checking i used system.out.
See my update for an example.
Péter Török
I don't know the task queue API, this is basic servlet stuff so far. You will need to experiment / google yourself...
Péter Török
ya thank you. I used your code as it in my example It display the title and body text but the process in the worker servlet is not called... do you know what problem it is please help me