File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "response.sendRedirect issue" Watch "response.sendRedirect issue" New topic

response.sendRedirect issue

Adi Kulkarni
Ranch Hand

Joined: Mar 12, 2009
Posts: 86

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 ?


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.!!!
Amit Ghorpade

Joined: Jun 06, 2007
Posts: 2848

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

|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.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63552

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] [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.


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.

I agree. Here's the link:
subject: response.sendRedirect issue
It's not a secret anymore!