permaculture playing cards*
The moose likes Servlets and the fly likes how to know cookies and script disabled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "how to know cookies and script disabled " Watch "how to know cookies and script disabled " New topic
Author

how to know cookies and script disabled

jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
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

Joined: Feb 20, 2001
Posts: 3695

*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

Joined: Jan 08, 2001
Posts: 2164
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

Joined: Feb 20, 2001
Posts: 3695

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

Joined: Jun 25, 2001
Posts: 15959
    
  19

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!).


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to know cookies and script disabled
 
Similar Threads
Need some help regarding sessions
How to use ckookie in jsp
about cookies
Session
session issue