• 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

Saving servletresponse object after service method executes

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Is it possible to save the httpservletrequest, httpservletresponse object after the servlet doPost or doGet or service method executes.

I am using tomcat 5.5 and looking at options in jdk to queue up http requests and process them asynchronously.
I am presently trying to implement ThreadPoolExecutor. However the caller thread is blocked till the job executes and returns.

To achieve asynchronization, is there a way to store the request, response objects after the service method executes so that the queue process can process these when their time comes and also servlet thread is released?

Please let me know.

Thanks,
Ravi
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No. You cannot save them.

They already execute asynchronously. Why are you trying to get in the way of that?
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would not be a good idea to save the request or response objects to be used when the service method would have been completed the execution. reason being their life cycle would have completed till that time.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ravi D shankar wrote:

To achieve asynchronization, is there a way to store the request, response objects after the service method executes so that the queue process can process these when their time comes and also servlet thread is released?



As you start reading and working, the Request and Response are for a request and they are short lived. Once the request processing is completed, they are ceased.

If at all you intend to say the data inside the request/response objects for the further use of ThreadPoolExecutor, you can very well save it in (files, database etc.,)

You can even do it it with a bigger scoped objects like Session, Application (ServletContext). But again, in this case they would have to be accessed via next set of request-response pairs
 
This. Exactly this. This is what my therapist has been talking about. And now with a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic