• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Issues with HttpServletResponse.sendRedirect to JSP/JSF file

 
nena tamari
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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


 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use as in
 
nena tamari
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
where do you put the sendRedirect code? and how do you getting the response object?
 
nena tamari
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic