Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Question about Servlet's RequestDispatcher forward / file paths

Reply
Thread Tools

Question about Servlet's RequestDispatcher forward / file paths

 
 
Harry
Guest
Posts: n/a
 
      12-22-2005
I've written a servlet that takes an XML request and responds with a
forward to a JSP.
This will essentially produce an HTML output for the response.
My question is how I can preserve the context file paths for the HTML
(as all the images referenced from the HTML appear as broken).

e.g.
// After processing the XML request, program forwards to a JSP as
follows.
RequestDispatcher rd =
request.getRequestDispatcher("/displayCustDetail.do");
rd.forward(request, response);

The above action will generate an HTML output (generated by the JSP) as
the response.
The HTML output is correct when I output to a browser window. Only
problem is the paths in the HTML do not have any reference to the
"http://host name" and the images all appear as broken..

e.g. currently showing as <img src="/appName/images/welcome.gif">

How do I preserve the correct context paths?

Harry..

 
Reply With Quote
 
 
 
 
Viator
Guest
Posts: n/a
 
      12-22-2005
You are giving an absolute path by appending a "/" in front. If you
want an absolute path see getConetxtPath() method or HttpRequest
object. If both the request and response are in same context ypu can
use relative path instead.

Any way for a side note, the .do extension is a convension of Struts
and there you do not use RequestDispatcher generally with Struts.


Amit

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
jsp include or RequestDispatcher.forward() need to identify 301's christopher@dailycrossword.com Java 0 08-29-2009 09:44 PM
RequestDispatcher and usage of forward slash harryos Java 2 12-17-2008 01:30 AM
RequestDispatcher.forward() not throwing IllegalStateException. Jan van Mansum Java 0 07-23-2006 10:18 AM
RequestDispatcher.forward() Taking 30 Seconds Each Will Handley Java 1 12-10-2003 11:52 AM
Convert between Windows style paths and POSIX style paths Noah Python 5 07-11-2003 09:25 PM



Advertisments