• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JavaScript and JSTL

 
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic