aspose file tools*
The moose likes JSF and the fly likes Issues with HttpServletResponse.sendRedirect to JSP/JSF file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Issues with HttpServletResponse.sendRedirect to JSP/JSF file" Watch "Issues with HttpServletResponse.sendRedirect to JSP/JSF file" New topic
Author

Issues with HttpServletResponse.sendRedirect to JSP/JSF file

nena tamari
Greenhorn

Joined: Sep 21, 2011
Posts: 8
Hi All,

I have this strange issue - I have a servlet that needs to do a redirect to a JSF page after checking some credentials are properly entered in the application.

If I do something like response.sendRedirect("/faces/success.jsp"); - i get 404 NOT found.

If I do something like response.sendRedirect(request.getContextPath() + "/faces/success.jsp"); - i get a BLANK PAGE!

(and by the way I have tried encodeRedirect as well - same thing.

I'm using Weblogic 10.3/JDeveloper 11G/JSP/JSF 1.2

Thanks in advance!
nena tamari
Greenhorn

Joined: Sep 21, 2011
Posts: 8
By the way - i just tried getServletContext().getRequestDispatcher(page).forward(request, response);

AND THIS WORKS - But why doesn't the redirect work? Why does it return a blank page every time?

roby george
Ranch Hand

Joined: Sep 08, 2010
Posts: 31
Hi,

Hope you know that in forword we get req and res object but not in case of sendredirect.


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Use as in
nena tamari
Greenhorn

Joined: Sep 21, 2011
Posts: 8
Yes, I understand that it forwards the reqest and response. However, in this case my page doesn't require the request/response objects from the previous screen. So what gives? Why doesn't it work?

response.sendRedirect(request.getContextPath() + "/faces/success.jsp") - DOES NOT WORK - results in BLANK PAGE.

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

where do you put the sendRedirect code? and how do you getting the response object?
nena tamari
Greenhorn

Joined: Sep 21, 2011
Posts: 8
I figured out what the problem was - one of my filters had a scenario where it wasn't propagating the filter with a chain.doFilter(....) - it now works!

Thanks for replying
sachin hadawale
Greenhorn

Joined: Jun 11, 2012
Posts: 4
Hi nena,

you can refer below link. I was also facing somewhat similar problem. I got the solution which is working proper. might it will help you also...

http://www.coderanch.com/t/583693/BEA-Weblogic/sendRedirect-request-dispatcher-not-working


Sachin Hadawale
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issues with HttpServletResponse.sendRedirect to JSP/JSF file