• Post Reply Bookmark Topic Watch Topic
  • New Topic

JavaScript and JSTL  RSS feed

 
Oliver Rensen
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

can I mix JavaScript and JSTL?

<script type="text/javascript">
if (document.layers) {
window.location.replace("<c:url value='/frameset.html' />");
} else {
if(self == parent) {
window.location.replace("<c:url value='/frameOrderList.jsp' />");
}
}
</script>

I get the error-message:
The requested resource (/SipReports/%3Cc:url%20value=) is not available.

Can I use the JSTL-tag c:url within JavaScript,
or is there another possibility for URL-rewriting
in JavaScript?

Kind regards

Oliver
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Javascript isn't interpreted on the server.
As far as the JSP compiler is concerned, it's just text.
So... yes you can mix the two in your JSP code.

If you look that the HTML source in your browser, you'll see the result of the JSP's execution
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the source and see that your <c:url> tag is still there, it means that you've got a setup issue that's causing the tag to not be interpreted correctly.

It has nothing to do with mixing JavaScript and JSTL.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. You may find this article informative.
 
Oliver Rensen
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have solved the problem. I forgot to insert
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
into the JSP, and I have thought it was a JavaScript-problem.

You see, I am a really experienced JSP-developer.
(just kidding)

Ben & Bear, thank you for the quick help.
You pointed me in the right direction.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!