File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Getting problem while redirecting the URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting problem while redirecting the URL" Watch "Getting problem while redirecting the URL" New topic

Getting problem while redirecting the URL

tushar borole

Joined: Oct 13, 2008
Posts: 12

I am using response.sendRedirect() to redirect the URL.
The URL format is as below

http://<host ort>/context?<param1=val1>&<param2=val2>&<param3=val3>

code is as below

redirectURL = http://<host ort>/context<param1=val1>&<param2=val2>&<param3=val3>
[Note : runtime host, port, all params and values are getting populated correctly.]


Now , I can see the generated url in address bar with 403-forbidon error.

But if I re-entered the same url, it will work properly. It means I need to re-enter the url, then it will show the result.

Do any one have pointers to resolve this issue?

As per my analysis, if the redirect url dosen't have any context path then it is working fine. e.g.

Pankaj Misra

Joined: Dec 28, 2008
Posts: 11
Could you please post your fully constructed URL, it will help debug the root cause.
tushar borole

Joined: Oct 13, 2008
Posts: 12
Hi ,

The constructed url is


The above url is not working when I am passing it to sendRedirect().

But if I re-enter the same url in same window or another window it is perfectly working.

Do you have any pointers to resolve this.
RaviNada Kiran
Ranch Hand

Joined: Jan 30, 2009
Posts: 528
Did you tried using the method encodeRedirectURL and return type of it into sendRedirect()??

If you want something you never had do something which you had never done
I agree. Here's the link:
subject: Getting problem while redirecting the URL
It's not a secret anymore!