Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

URL Rewriting  RSS feed

 
Deepan Devadasan
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • 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..
 
Sathish Nagappan
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!