• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RequestDispatcher include Problem

 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as my understanding the include method of RequestDispatcher icludes the response of some other resource into its contents....
What will happen if the Included servlet is commiting the response??
And if we try to write any data to response after include, then will it throw IllegalStateException??
I mean something like this...

out.println("Data Begins");
RequestDispatcher lRd = lResponse.getRequestDispatcher("/servlet/Test); // Test commits the reponse
lRd.include(request, response);
out.println("will it throw exception??");
[ November 27, 2003: Message edited by: Andy Smith ]
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think it will throw IllegalStateException, because you are using include method of the RequestDispatcher and it will not forward the request to the servlet permanently... So the process will be going on, after the include method is returned..
 
Andy Smith
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Naing.. But when we include the resource using Dispatcher we pass the same request, response of object that we have in the calling servlet...
If the Called servlet commints that response... then obviusly the reponse object of the calling resource is comminted...
I hav adoubt...
i will Run a Sample Test for this.... will let u know...my findingd..
Thanx again
[ November 28, 2003: Message edited by: Andy Smith ]
 
Jamie Martel
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andy,
Did you run your test? I'd be interested in your findings :-)
 
Anselm Paulinus
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the called servlet commits the response; I do not believe that the response headers of the calling servet is commited because the called servlet supposedly ignores the changes in the response header, when the call returns and resumes with its previous headers I suppose.
Would love to know the outcome of your test.
 
Sandesh Tathare
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with what Anselm Paulinus has just mentioned.
That's what Theory says. Now let's see whether it works in practise or not.
Waiting for your test results.
Sandesh
 
cyril vidal
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
As from theory expected

The ServletResponse object has its path elements and parameters remain unchanged from the caller's. The included servlet cannot change the response status code or set headers; any attempt to make a change is ignored.

the practice says: no IllegalStateException is thrown.
By the way, the test was really not hard to do...took 2 minutes ..
Regards,
Cyril.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic