Forums Register Login

jsp and javascript

+Pie Number of slices to send: Send
I want to alert some variables declared in JSP %>(scriptlet)
if I use
alert("<%var%>");
It is creating problem.
i read in some forums, it is given we have to create
JSObject for this.I am not clear.
Please help.
Thanx.
+Pie Number of slices to send: Send
 

Originally posted by unna kumar:
I want to alert some variables declared in JSP %>(scriptlet)
if I use
alert("<%var%>");
It is creating problem.
Thanx.


hi
i think u have missed "=" in ur alert.Here's a sample code that i created and it is working
<%@ page language="java" %>
<HTML>
<%
String svar="hemanth";
%>
<script language="JavaScript">
function check()
{
alert("<%=svar%>");
}
</script>
<body onLoad="check()">
hi there
</body>
</html>

Hope this helps
+Pie Number of slices to send: Send
ThankYou Hemanth.
It is working.
unna
It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 791 times.
Similar Threads
passing a jsp variable as an argument to he javascript
How to stop the execuation of jsp flow
Conditional alerts (was 'c:otherwise tag')
Javascript code inside JSP (error in flushing)
display ActionErrors in JavaScript AlertBox
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:19:45.