aspose file tools*
The moose likes Servlets and the fly likes response.sendRedirect issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "response.sendRedirect issue" Watch "response.sendRedirect issue" New topic
Author

response.sendRedirect issue

Adi Kulkarni
Ranch Hand

Joined: Mar 12, 2009
Posts: 86
Hello,

I have a servlet which has a some logic after which it does a send redirect.

response.sendRedirect("url") ;
Now this works fine on my local setup and the url page is displayed properly. However, when I try it on a different setup, the url shows a servlet name and the page is blank.

What might be the reason for this ? . There is a return statement after the redirect.

Is it some problem with the redirect ?

thanks,
Aditya


SCJP 1.5
Pravin Shirke
Ranch Hand

Joined: Apr 05, 2008
Posts: 150

Hi Adi,
Can you post the url please. whether it is relative url or absolute url? which you have used?


[Vipassana] - It is seeing the reality as it is, And not as you want it to be.!!!
SCJP1.5.
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2713
    
    5

You need to check the url and a return statement after a redirect is not really helpful.
Are you sure there is no exception?


SCJP, SCWCD.
|Asking Good Questions|
Adi Kulkarni
Ranch Hand

Joined: Mar 12, 2009
Posts: 86
The URL is relative. Its something like . response.sendRedirect("confirmation.jsp")

I can't see the logs for exception because its on some other machine. But I'm puzzled because its working properly on my local setup.

Also, just the redirect is not happening and all the backend updations are happening.

thanks,
Aditya
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60077
    
  65

Adi Kulkarni wrote:The URL is relative. Its something like . response.sendRedirect("confirmation.jsp")

Page-relative URLs are very fragile. The first thing I'd do is to change this to a server-relative URL that begins with the context path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Adi Kulkarni
Ranch Hand

Joined: Mar 12, 2009
Posts: 86
Thanks a lot Bear,

I noticed that our url has some blank spaces.

Example


response.sendRedirect("confirmation.jsp?a=<variable1>&b=<variable2> &c=<variable3>")


Will this blank page cause issues. Also from the log trace that we have got, the sendRedirect is getting called and after that there is some user defined exception.

Thanks,
Aditya
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: response.sendRedirect issue
 
Similar Threads
Issues with HttpServletResponse.sendRedirect to JSP/JSF file
servlet to servlet communication
Crazy sendRedirect() problem -- Urgent
Servlet to html
response.SendRedirect and session