Get your CodeRanch badge!*
The moose likes Servlets and the fly likes why should HttpServletResponse.sendRedirect lead to a blank page? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "why should HttpServletResponse.sendRedirect lead to a blank page?" Watch "why should HttpServletResponse.sendRedirect lead to a blank page?" New topic
Author

why should HttpServletResponse.sendRedirect lead to a blank page?

Sindhu java
Greenhorn

Joined: Nov 02, 2011
Posts: 2
Hi ,
I found some hints from the below post but still i am not sure how to fix the issue
http://www.coderhanch.com/t/554960/JSF/java/Issues-HttpServletResponse-sendRedirect-JSP-JSF


Could you please let me know how this was fixed ?

Below is the Code snippet. - In one of the flows there is a ServletException and so as per the logic it should redirect me to the Logout page however it leads me to a BLANK PAGE.
The url also doesnt change.

try
{
filterChain.doFilter(request, response);
}
catch(ViewExpiredException e)
{
HttpServletResponse httpServletResponse = (HttpServletResponse)response;
httpServletResponse.sendRedirect("authentication/LogoutServlet");
}
catch(ServletException e)
{
HttpServletResponse httpServletResponse = (HttpServletResponse)response;
httpServletResponse.sendRedirect(httpServletResponse.encodeRedirectURL(httpServletRequest.getContextPath()+"/logout.jsp")); //------This doesnt work- i just get a BLANK PAGE.

}

Many Thanks.

Thanks and Regards,
Sindhu
Sindhu java
Greenhorn

Joined: Nov 02, 2011
Posts: 2
I was referring to the below link

http://www.coderanch.com/t/554960/JSF/java/Issues-HttpServletResponse-sendRedirect-JSP-JSF#2517867
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

What does a View Source in the browser show? A blank page? Bad HTML? Does the page display correctly when the URL is typed into the browser by hand?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
abani patra
Ranch Hand

Joined: Oct 11, 2011
Posts: 70
Hi,
In response.sendRedirect do not use context path.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60046
    
  65

Incorrect. In a redirect, the context path must be used.t
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why should HttpServletResponse.sendRedirect lead to a blank page?
 
Similar Threads
Handling double submit at server side, displays balnk page.
Filter URL mappings
exception handling
Thread running withing a servlet
JSF Filter prevent direct access certain page