0
votes

I have a jsp:

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
hello
<c:import url="/scripts/script.js"  var="under" context="/"/>
<c:out value="${under}"/>
bye

"script.js" refers to an external file. However, when I add that statement, the import always grabs the file that I am working on instead. I get the following output:

"hello <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> hello bye bye"

Why is this? What can I do to point to the correct jsp?

1
Do you have the JSTL libraries in the classpath? - Paul Vargas
You're saying that without the import the page works correctly including properly dealing with the directive? - Dave Newton
why don't you use directly use the <script>? - Abubakkar
Go to http://localhost:8080/scripts/script.js. What do you see? - BalusC

1 Answers

0
votes

Is your script (/scripts/script.js) contains "bye"?

  • I can c:out is working fine so JSTL library is in classpath ( ruled out)
  • We can see out for under var (bye in this case)

That clearly says your javascript file should contain "bye".