• 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

RequestDispatcher include Problem

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Andy,
Did you run your test? I'd be interested in your findings :-)
 
Ranch Hand
Posts: 390
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic