Thomas,

The servlet is already handling your request in a dedicated thread.
Why is it that you want to create another one. It appears that your
thread is just handling the request--which is what the servlet's thread
is doing. Is there something else you want to use the thread for?

--jeff

Thomas To wrote:

> Hi,
>
> I'm trying the start a thread inside the servlet and encounter a
> problem.  When the start() method get executed, the client (Brower)
> immediately receives "Document contains no data".
>
> Following is part of the doGet() method in the servlet:
>
> public void doGet (HttpServletRequest request,
>           HttpServletResponse response)
> throws ServletException, IOException
> {
>      // Get the user's session and shopping cart
>      HttpSession session = request.getSession(true);
>
>      // as soon as this method is called, client receive "no data" error
>      temp.start();
>      .....
> }
>
> and following is code of my simple Thread object:
>
> public class OhServletThread extends Thread
> {
>      ServletRequest m_req;
>      ServletResponse m_res;
>      HttpSession m_session;
>      private PrintWriter m_out;
>
>      // constructor
>      public servletThread(ServletRequest req,
>             ServletResponse res, HttpSession session)
>      {
>           m_req = req;
>           m_res = res;
>      }
>
>      public void run()
>      {
>           // set content-type header before accessing the Writer
>           m_res.setContentType("text/html");
>
>           try
>           {
>                m_out = m_res.getWriter();
>                m_out.println("This is a test");
>           }
>           catch (IOException ome)
>           {}
>
>           m_out.close();
>      }
> }
>
> Can a servlet start a Thread object at all.  Any help is greatly
> appreciated.
>
> - Thomas -
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to