Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can't redirect to another page

 
Nada Bajnaid
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the value of location = (String) request.getParameter("location"); ?
 
Nada Bajnaid
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is a string containing the new URL. You can see it works with the href tag
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes finaly it works. Many thanks
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nada Bajnaid wrote:Yes finaly it works. Many thanks

You are welcome
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is all about location... ;)

location-location.jpg
[Thumbnail for location-location.jpg]
Location, location, location...
 
abani patra
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please use Request Dispatcher or send redirect methods .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic