• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP Redirect/Refresh Options

 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a website in which all my links are stored in the db and the actual URL of the link is not shown unitl the user clicks on my db encoded link.
ie. http://localhost/jetspeed/jsp/display.jsp?linkid=75
display.jsp bascially logs info about the user who clicked, on the link, time, etc.
After which it looks up the url in the db by referencing it through the the linkid. After which a <META HTTP-EQUIV=Refresh CONTENT="0; URL=<%= next_url %>"/> is used to get to the next page.
The onyl problem about this is that the Referrer variable is lost in the process. I think that is part of the Browser info or something???
Is there a better way to do this?
 
Gerd Rosarius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anthony,
why don't you just add/encode the referrer to the URL, like
http://localhost/jetspeed/jsp/display.jsp?linkid=75&referrer=http://sitexyz.html
On your next JSP you can get the referrer by

Greetings
H.-Gerd Rosarius
 
Gerd Rosarius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anthony,
here the answer to your private message:
What I described in my last posting is exactly what you need.
Get the surfer's referrer and do your database stuff on, say page1.jsp. When you are finished, encode the URL to which you want forward the surfer as described earlier.
After that don't use the META HTTP-EQUIV=Refresh-stuff to forward the surfer. With some web-browsers you'll get trouble. (NS4.7 for example)
Use
instead.
Or use the fully encoded URL as target for a button, if you don't want to redirect automatically.
The surfer will get forwarded and you can still access the referrer as described in my last posting.
Does this clear some clouds or didn't I get your problem?
Greetings
H.-Gerd Rosarius
 
Anthony Smith
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I have gotten a lot farther, but....
It seems as if I cannot fake the referrer variable.
response.sendRedirect( response.encodeRedirectURL( next_url + "&referrer=http://www.myserver.com" + referrer ) );

This works, but even if I leave off the referrer object, it does not matter. It keeps the real referrer. SO can you not make the referrer anythign that I want?
 
Gerd Rosarius
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Anthony,
basically you can do with the parameter 'referrer' whatsoever you want.
Is your String object 'referrer' a fully qualified URL (beginning with http )?
If so, your code on - say page1.jsp - should be

On your target page - say page2.jsp - you access it by
Voil´┐Ż, you get your referrer.
H.-Gerd Rosarius
[ February 22, 2002: Message edited by: Gerd Rosarius ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!