From a .js file i am trying to create a reusable variable of a jsp function for example.
Does anyone know how the js file can grab a jsp function from the jsp page for example trying something really simple.
++jsp page++
<html>
<head><title></title></head>
<script SRC = 'mysource.js' language="JavaScript">
<body>
<import%@ java.util.Date" %>
</body>
</html>
+++mysource.js+++
//called when i need it through a javascript function on the jsp page
function retrieveDate() {
var dateStored = <%= new Date() %>
}
-
JavaScript and JSP (3 messages)
- Posted by: Joey H
- Posted on: November 08 2000 00:44 EST
Threaded Messages (3)
- JavaScript and JSP by Steve Finck on November 08 2000 18:01 EST
- JavaScript and JSP by Steve Finck on November 08 2000 18:05 EST
- thankx steve by vijay anand on March 09 2005 07:26 EST
- JavaScript and JSP by Steve Finck on November 08 2000 18:05 EST
-
JavaScript and JSP[ Go to top ]
- Posted by: Steve Finck
- Posted on: November 08 2000 18:01 EST
- in response to Joey H
Joey,
I don't believe this will work. By using a js file your jsp will never get processed. Either place everything in your JSP, or create mysource.js as a JSP and use the JSP include tag instead, see below:
--------------------
++jsp page++
<html>
<head><title></title></head>
<%@ page import="java.util.Date" language="java" %>
<%@ include file="mysource.jsp" %>
<body>
</body>
</html>
+++mysource.jsp+++
//called when i need it through a javascript function on the jsp page
function retrieveDate() {
var dateStored = <%= new Date() %>
}
--------------------
Does that help?
Steve -
JavaScript and JSP[ Go to top ]
- Posted by: Steve Finck
- Posted on: November 08 2000 18:05 EST
- in response to Steve Finck
I forgot one thing ... add the javascript tags to your mysource.jsp file so it looks like this:
----------
+++mysource.jsp+++
//called when i need it through a javascript function on the jsp page
<script>
function retrieveDate() {
var dateStored = <%= new Date() %>
}
</script>
----------
Steve -
thankx steve[ Go to top ]
- Posted by: vijay anand
- Posted on: March 09 2005 07:26 EST
- in response to Steve Finck
thankx for the information steve.
Ofcourse We can do that. but I don't want to write javascript for any reason.instead How can i validate the object with jsp <% %>
example: I want change the values of combo box two depending on the values select in other combo box one .
can u help me to this