aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes How to detect javascript from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to detect javascript from jsp" Watch "How to detect javascript from jsp" New topic
Author

How to detect javascript from jsp

Salman Bashir
Greenhorn

Joined: Aug 11, 2005
Posts: 3
Hello all,

How can i get to know about the Javascript i.e., whether it is enabled or disabled at server side. Also how can i get the javascript version from jsp.

I can not use values stored (e.g., hidden form fields) by javascript in the jsp page. Just need to know the version and js enabled/disabled information from the server side right after getting the hit from the client.

Thanks for your help,

Regards

Salman Bashir
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You won't know on the first hit but if your page has a form, you can test when that form is submitted.

In your form, add one hidden field.
Then from the form's onsumbit or the body's onload event, change the value of that field.



From your servlet/jsp, read that parameter with request.getParameter.
If it's "true" then you know that javascript was enabled when the form was submitted.

I don't know how to get the version.
The User-Agent header will tell you what make and version browser the user has (or which one they're claiming to have anyway).
[ August 12, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Salman Bashir
Greenhorn

Joined: Aug 11, 2005
Posts: 3
Thanks Ben Souther

I already am using this mechanism, but i want to know a mechanism by not setting any value from javascript.

I mean is there any way to getting the javascript version + enabled/disabled information from the server side, i.e., may be by using an HTTPServletRequest class or some other class providing this mechanism.

Thats what i meant initially.

Thanks for your response, and still waiting for suggession regarding this problem.

Regards,

Salman Bashir
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Nothing JSP-specific about this, so moved to the HTML forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I am not sure if this is possible. I don't believe the HTTP headers contain any information such as if the browser has enabled/disabled JavaScript, just like I don't believe it will contain information if the browser will allow PopUp windows.

I think your best suggestion is to store this information in a hidden field and access this information thru the HttpServletRequest object.

But, I could be wrong, I am not an expert. I, also would be interested in a solution.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to detect javascript from jsp
 
Similar Threads
Determining if cookies are disabled via Servlet/JSP
Qus on validator framework
how do identify javascript enabled browser
Checking browser version & JavaScript enabled
detect if javascript is enabled/disabled