File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet Response

 
Scott Stanlick
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a strange situation where writing to the response writer works but performing a requestDispatch.include(rq, rs) does not! What I want to write to the response is the result of a jsp that I am trying to include. Am I missing something basic here? Is include different from writing directly to the response writer?

Peace,
Scott
 
Joy Mukherjee
Ranch Hand
Posts: 62
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you trying to get the dispatcher using ServletContext or ServletRequest ?
 
Scott Stanlick
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Using:

RequestDispatcher dispatcher = request.getRequestDispatcher(getLocation());
dispatcher.include(request, response);

Shouldn't the output of the "included" JSP be the same as writing directly to the response?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64192
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is happening?
 
Scott Stanlick
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The response is being evaluated by a java script function and when I write to the response myself it works okay. If I include a JSP (that is the same content) it is as though there was no response at all! Is there a way to examine the response following the .include?
 
Amol Nayak
Ranch Hand
Posts: 218
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post more portion of your code so that we have understand better what the problem might be?
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11833
181
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Scott,

Please check your private messages for an important administrative matter.

Thanks, Andrew
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13048
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to examine the response following the .include?


If you mean examine what is actually sent to the client - sure. The Firefox browser has great plugins that will capture and show all the bits sent to a web page. I like the Firebug plugin.

You can seee exactly what Javascript is doing, etc etc.

Bill
 
Steve Luke
Bartender
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show a full method that makes the .include call and misbehaves? And the JSP that is included as well?

If these are very large please make a mock up that behaves the same way but is a minimal example.

Can you also check your logs and see if an exception occurs during the process? Sometimes these errors get hidden when using JSPs and Servlets because part of the page has been committed before the error occurred.
[ August 17, 2008: Message edited by: Steve Luke ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic