• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

URL Rewriting

 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

My knowledge on this area is very poor and i am confused as well..

Simply
response.encodeURL("/blahblah.jsp");
is fine....

The confusion comes here..

We as the developers don't know whether the client supports cookies or not...

So dont love to take chances...

The option is this..
Devise a way to check whether the cookies are enabled on the client's front..

If enabled-no problems...

If not-- we should fall back to URL Rewriting...

Can some clarify the flow, potentially with some code samples...

Adding to the baking issue, is <c:URL> of jstl..
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to do that evaluation in code.

Your container might have the option to automatically turn on URL Rewriting when cookies are not supported by the client.

Here is how a dumb container might handle it:

Whether cookies are enabled or not in the client, it will send a cookie and do URL Rewriting at the same time.

But here is how a decent container automatically handles it:

When the request.getSession().isNew() returns false() while executing a servlet, it means that a cookie was sent to the client and it has been sent back (which means the client supports cookies).

Hence the container will automatically turn on URL Rewriting wherever encodeURL() is being used.
 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi..

So we as developers can use encodeURL() always assuming container will handle the rest...

Then again, if we can get to know whether the browser supports cookies, we avoid the code related to URL rewriting....

Hope my assumption is correct
 
Sathish Nagappan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What I was saying is that, You do not have to check if the browser supports cookies or not. This cookie/URL-Rewriting is guaranteed to work for every container by the J2EE spec, provided you encode all your hyperlinks using encodeURL(). The container will automatically do the cookie/ URL-Rewriting switching for you.
 
What are you saying? I thought you said that Santa gave you that. And this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic