• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread Issue In The Servlet

 
Khirod Patra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

In a Servlet ,I want to execute a method as a background process.I used this method inside the Servlet becase It use the
request object.So I create a Thread through a inner class inside the servlet. The Thread execute and works fine upto the servlet
has not been redirect to jsp,The moment it redirect the run() method from Thread returns NullPointerException.

So Here what I need

I want to execute the Thread with out depends the redirection of servlet.I mean as a backgroud process.In the Thread I have to use the request object of the Servlet.

Let me Know if anything required from myside..

Please Help me Out..


Thanks & Regards
Khirod Patra
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used this method inside the Servlet becase It use the request object.


NO - do NOT keep a reference to the request object - it must be managed by the servlet container. It is time to redesign!

You will find that the servet API provides simple methods for extracting ALL of the information in a request if you have to provide this to another process.

Bill
 
Khirod Patra
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the response,

Is there any other way , That we can manage a dummy request object for this job



Thanks & Regards

Khirod Patra
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you need the request object for? As Bill said, you can get all the information from it, pass those to the background job, and then let it do its work. Servlet API objects should only be used in the view layer, not in the deeper layers.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic