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.
SCJP, SCWCD, SCBCD, IBM XML, IBM OOAD, SCEA 5, ITAC - Distinguished IT Architect.