• Post Reply Bookmark Topic Watch Topic
  • New Topic

encode

 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
how do i encode the URL shown in the address bar.
i.e i have a url <a href="http://www.abc.com/servlets/display?user=\""+ userid +"\"">Display</a>
but when the user clicks on the link the same URL should not be shown n it should be encrypted in some way. or session id should be appended to it..
how cud it i possibly do it..
thanks in advance
malhar
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if I completely understand what you're asking.

If I were using your website, and I clicked on "http://www.abc.com/servlets/display?user=345" you want the address bar to *not* show this URL?

One way to do this is by having the display servlet use something in the URL that is clicked (some identifying number)... this number will match up with the 'real' URL. Then have the servlet use response.sendRedirect(). This will make the browser's address bar show the URL of the 'real' page you wanted, and not what the user clicked.

As for the other part, 'encrypting' an URL and appending a session id are not really two things I'd place on either side of an 'or'.

One way to force the URLs to have the session id included is to send *all* URLs (from JSP's and servlets) through the response.encodeURL() method. The additional step you'd have to take, is to set up your container to use ONLY URL rewriting (ie: No cookies). This will ensure that the URLs for your site always contain the session id.

As for encrypting it? No idea.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!