javascriptjspjsp-tags

How to call JSP tags in JavaScript


Is it allowed to call JSP tags inside JavaScript file like the following example which uses Spring MVC tags:

<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>

function displayErrors() {  
   alert("<form:errors path='*'>");
}

If allowed, how to make it work correctly?


Solution

  • This is JSP

    <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
    
    <script>
    function displayErrors() {  
       alert("<form:errors path='*'>");
    }
    </script>
    

    You can use JSP tags inside JSP file, not JS file.