Win a copy of Spark in Action this week in the Open Source Projects forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

ReequestDispatcher include()

Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Running on Websphere 3.5.4 the following code....
for (int i = 0; i < controllers.length; i ++) {
rd = getServletContext().getNamedDispatcher(controllers[i]);
if (rd == null) {
throw new ServletException("Controller " + controllers[i] + " does not exist");
} else {
log("Including Cont Servlet : " + controllers[i]);
log("Point 3a : " + response.isCommitted());
rd.include(request, response);
log("Point 3b : " + response.isCommitted());
Can anyone please tell me why the response is commited at point 3b? This should not be so, and indeed isn't when run under tomcat 4.0.
Furthermore, extract from javadocs indicates....
Includes the content of a resource (servlet, JSP page, HTML file) in the response. In essence, this method enables programmatic server-side includes.
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.
I am includind a servlet DoNothingServlet that does absolutely nothing and even if it was it shouldn't be altering the headers as the above Servlet javadoc indicates....
This is preventing me from later forwarding to a JPS page, as it stated the response is already commited. anyone got any ideas if I'm doing anything wrong...
I have used this design successfully in Tomcat 4.0 for some time.
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't realy understand what you are trying to accomplish, but it looks like a buffer problem. The default buffer size is supposed to be 8k, but from my experience IBM tend to do whatever they want.
I'd guess that in Tomcat you are finding that all of the included output fits in the buffer, but it doesn't in WS. So WS sends the response to the client and therefore commits the response.
As a matter of design, you should try to organise things so you never try to forward after you have started including content - they are incompatable and you can get pages that behave wierdly.
Robin M
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave,
Thanks for your feedback here.
I have got round the problem another way, a way that I think is actually a lot better as you can dynamically extend the web app without registering new servlets. Here is a link to the article I read if anyone is interested.
A very good way of using MVC in Web App design
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi dave,
from ur post i assume that if the included page size is more than 8k then it would have to commit the response to the client COMPULSORY.
correct me if i'm wrong...
though i will test this myself whenever i get time.
We don't have time to be charming! Quick, read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic