How to access HttpServletResponse in run() metho
1 posts in topic
Flat View  Flat View

Posted By:   Namrata_Rai
Posted On:   Wednesday, May 9, 2001 10:42 PM

Hello everybody,

I have to start a thread in the doGet(HttpServletRequest req,HttpServletResponse res) method of a servlet. The Printwriter out and res are accessible in doGet but not in the run() method of the sevlet. I wanna use res.sendRedirect() in the run(). The server is Apache Web Server with Apache JServ... so can u please tell me how to do it?

Re: How to access HttpServletResponse in run() metho

Posted By:   Alex_Chaffee  
Posted On:   Monday, May 21, 2001 01:13 PM

public MyThread extends Thread {
private PrintWriter myWriter;
public MyThread(PrintWriter writer)
myWriter = writer;
public void run()

public void doGet(...)
MyThread mt = new MyThread(response.getWriter());

This is a very dangerous technique, however, since the doGet() method may return before the thread finishes. So watch out. That's why you need the join() call.
About | Sitemap | Contact