File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Not including the template when usin RequestDispatcher Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not including the template when usin RequestDispatcher" Watch "Not including the template when usin RequestDispatcher" New topic
Author

Not including the template when usin RequestDispatcher

Priyam Srivastava
Ranch Hand

Joined: Oct 29, 2006
Posts: 169
This is a part of my Servlet code:

where company is an object of class Company.

though the browser is dispalying the registrationComplete.jsp page but the problem is that jsp uses a template "home.dwt" and it doesnot include the template (or the images) when the control is transferred from servlet to jsp page using RequestDispatcher...
but it displays the template contents correctly if I transfer the control from servlet to jsp page using sendRedirect() i.e

on my registrationComplete.jsp page i am using the following jsp code:


with sendRedirect() I would be getting a null value...

Can anyone tell why the template element is not displayed in the jsp while using RequestDispatcher()?

I also tried using:


PS: The attribute value is being displayed correctly when using RequestDispatcher.
[ February 23, 2008: Message edited by: Priyam Srivastava ]

"History would be kind to me, for I intend to write it."
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Your links are probably off when doing a server side forward.
The way to prevent this is to make all of your URLS (image src, form action, css href)s relative to the context instead of being relative to the page.
See:
http://faq.javaranch.com/java/ResourceUrlProblems
for a complete explanation.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not including the template when usin RequestDispatcher