aspose file tools*
The moose likes Servlets and the fly likes Servlet Response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Response" Watch "Servlet Response" New topic
Author

Servlet Response

Scott Stanlick
Greenhorn

Joined: Aug 06, 2002
Posts: 11
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

Joined: Aug 10, 2008
Posts: 62
How are you trying to get the dispatcher using ServletContext or ServletRequest ?


B.Tech (E.E),IIT Kharagpur<br />SCJP 5.0<br />SCWCD 5.0<br />PMP
Scott Stanlick
Greenhorn

Joined: Aug 06, 2002
Posts: 11
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

Joined: Jan 10, 2002
Posts: 60077
    
  65

What is happening?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Scott Stanlick
Greenhorn

Joined: Aug 06, 2002
Posts: 11
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

Joined: Oct 26, 2006
Posts: 218
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

Joined: Mar 28, 2003
Posts: 11285
    
  59

Scott,

Please check your private messages for an important administrative matter.

Thanks, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
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


Java Resources at www.wbrogden.com
Steve Luke
Bartender

Joined: Jan 28, 2003
Posts: 3970
    
  17

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 ]

Steve
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet Response
 
Similar Threads
Servel Response
Http response containing XML document
Servlet Response adding JSP page code to it
XML writing and reading to an URl
Capturing JSP Content Within My Strut Action Servlet