Jill Jill - 5 months ago 27
Java Question

Redirect if JavaScript is disabled in JSP itself

I want to redirect if JavaScript is disabled. I am using Servlets and JSPs. My Page redirections are totally in servlets. and i want to check it through jsp and want to redirect to servelet with coditions to get No JavaScript Page.

All other answers were for a fixed url like http://www.example.com/pagename.jsp, but I didn't want to show my .jsp page names anywhere outside the servlet.


Thats why I mentioned that every thing is in servlet controller.

Answer

Use this code in your Jsp files.

<noscript>
<meta http-equiv="refresh" content="0.0;url=?action=nojs">
</noscript>

Here "action" is a variable in your servlet which is used for decision taking.

You can change it accordingly.

Comments