Arip H Arip H - 1 month ago 17
Javascript Question

How to access JSP tag from JavaScript

Is it allowed to call JSTL tag inside JavaScript file like the following example :

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

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


If allowed, how to make it work correctly?

Answer

This is JSP

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

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

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

Comments