GeeCON Prague 2014*
The moose likes Servlets and the fly likes jsp and javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp and javascript" Watch "jsp and javascript" New topic
Author

jsp and javascript

unna kumar
Greenhorn

Joined: Oct 13, 2000
Posts: 11
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.
hemanth kumar
Ranch Hand

Joined: Mar 15, 2001
Posts: 55
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
unna kumar
Greenhorn

Joined: Oct 13, 2000
Posts: 11
ThankYou Hemanth.
It is working.
unna
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jsp and javascript