File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes response.sendRedirect();jsp:forward;<c:redirect> Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "response.sendRedirect();jsp:forward;<c:redirect>" Watch "response.sendRedirect();jsp:forward;<c:redirect>" New topic
Author

response.sendRedirect();jsp:forward;<c:redirect>

Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 180
Hi

In my jsp I want to forward the request to some other jsp based on a session attribute.

and bothe jsps are in same folder under webcontent. I am using Struts tiles.

I tried with "/index.jsp" and "./index.jsp" and "MyApp/index.jsp" and

Nothing is working


Please help me ...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Is there any content before this redirect?? If the response is committed before you redirect, you'll get this behavior...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Balaji Bang
Ranch Hand

Joined: Apr 23, 2007
Posts: 180
Before that I have Page imports ,

How to handle these kind of situations???
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Generally you should not face a situation where you have to redirect from a JSP. This means that you are putting logic into the JSP, which is not a very good idea. Anyways if you are just doing this for practice, move the logic above any content that you are generating instead of after the head tag...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: response.sendRedirect();jsp:forward;<c:redirect>
 
Similar Threads
Forward to different URL and pass parameters
Handling response.redirect errors in JSP page
JSTL redirect tag
scwcd doubt on jsp:forward
some problem with java beans scope attribute?