• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread Issue In The Servlet

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic