aspose file tools*
The moose likes Servlets and the fly likes Can't redirect to another page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can Watch "Can New topic
Author

Can't redirect to another page

Nada Bajnaid
Ranch Hand

Joined: Aug 14, 2011
Posts: 45
I tried the following code to redirect to another page



where location is the variable containing the new url. it opens new window but never redirected. When I placed a test message the message was infinitly writtin to the console

When I tried using href instead it works



But I don't the user to click to be redirected to the new page I want to redirect automatically. Can anyone see where I'm wrong?
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Nada Bajnaid wrote: When I placed a test message the message was infinitly writtin to the console

Dont you smell something here? *from where to where*, you are redirecting?
Nada Bajnaid
Ranch Hand

Joined: Aug 14, 2011
Posts: 45
I call this servlet from another servlet to do some action then redirect to the new page. I'll paste my code here


you can see that I comented the statement with the meta tag as I didn't work for me and use the href instead
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

what is the value of location = (String) request.getParameter("location"); ?
Nada Bajnaid
Ranch Hand

Joined: Aug 14, 2011
Posts: 45
it is a string containing the new URL. You can see it works with the href tag
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

formation of meta tag has problem, replace yours with below one.
out.println ("<meta HTTP-EQUIV=\"REFRESH\" content=\"2; url="+location+"\">"+"</meta>");
Nada Bajnaid
Ranch Hand

Joined: Aug 14, 2011
Posts: 45
Yes finaly it works. Many thanks
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Nada Bajnaid wrote:Yes finaly it works. Many thanks

You are welcome
Ove Lindström
Ranch Hand

Joined: Mar 10, 2008
Posts: 326

It is all about location... ;)




[Thumbnail for location-location.jpg]

abani patra
Ranch Hand

Joined: Oct 11, 2011
Posts: 70
Hi,
Please use Request Dispatcher or send redirect methods .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't redirect to another page