How to determine if javascript is enabled or not in a browser through Java

I want to know that there is some way by which I can determine if Javascript is enabled in the browser. How can we detect cookies using the code in the filter

if (httpServletRequest.isRequestedSessionIdFromCookie()) {

}

Can I also define javascript? Does Java provide any method for this? Actually I want to check if javascript and cookies are enabled. If not, then I want to show the user a message that Please make sure your cookies and javascript are enabled

thank

+3
source share
1 answer

There is no way to check this on the server side. You must allow the client to somehow notify the server side of this.

JS cookie .

<h:outputScript>
    if (document.cookie.indexOf('js=true') == -1) {
        document.cookie = 'js=true';
        window.location.reload(true);
    }
</h:outputScript>
<h:panelGroup rendered="#{not cookie.js.value}">
    Please make sure that Cookies and JavaScript are enabled.
</h:panelGroup>

JS , cookie = js=true, ( cookie ). , , JS . JSF rendered , cookie js true, . :)

+2

All Articles