Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Saving servletresponse object after service method executes

 
ravi D shankar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65228
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic