Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to know cookies and script disabled

 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well What technique we should apply to know that cookies are disabled in browser so we can start url Rewriting.Also how can we know about script disabled.
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
*you* don't really have to know if cookies are disabled, as the encodeURL method on the response object will either
a)not rewrite the URL because cookies are enabled
or
b) rewrite the URL because they are disabled (or refused).

So it's at least partly transparent to you.

Not too sure about detecting if scripting is disabled. You can't do it with JSP code, because that's the server side, and it doesn't know anything about the client. And you can't do it client side, because what script will you run to check, if scripting is disabled?

That last bit was me thinking out loud.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mike Curwen:
Not too sure about detecting if scripting is disabled.[...]And you can't do it client side, because what script will you run to check, if scripting is disabled?

That last bit was me thinking out loud.

I havent tried it with code but it should be possible to use a hidden field called jsEnabled and a script document.forms[0].jsEnabled.value="yes" in onLoad event of the body tag. You can check then this field in the servlet. If the field-value is not yes JavaScript is disabled.

Axel

 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which would require at least a single request-response cycle before the server side would know about it. So perhaps on the index page?

To be clear.. the javascript would set the flag if it was able to.. but JSP/Servlets would only know this after that page's form was submitted.
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are 2 good reasons to have a web app's home page be an HTML page.
First, because it's the easiest thing to serve up. Only a major server failure is going to break it. Plus, a sloppy server config is more likely to look for an "index.html" page than something named, say, "firstpage.jsp" if the user types the URL with no explicit page name.
Secondly, it's a great way to snoop the client's capabilities, including cookies, JavaScript, client-side Java, and what browser they're using (suprise! not EVERYONE's running IE!).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic