Ken Adams wrote:
> Can and how does one put JSP code inside javascript code. Thanks
JSP can be written within a section of JavaScript, so long as it is
processed by the server before it is output, and the browser only
recieves the resultant JavaScript. If you were wanting a browser to
understand the JSP, then no, you can't.
eg. If this is your script.
<script type="text/javascript">
<%
/*
* Code to read from DB or other source, or whatever you need.
* Say, for example, the string "hello world" is returned, and
* set to the message variable
*/
message = "hello world";
%>
var msg = "<%=message%>";
alert(msg);
</script>
From the above JSP, the browser would recieve and execute the following
script:
<script type="text/javascript">
var msg = "hello world";
alert(msg);
</script>
--
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox