faqts : Computers : Programming : Languages : Java

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

55 of 64 people (86%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can we assign JSP variables to Java Script Variables

Jul 8th, 2008 05:06
Joe jack, suresh kc, Mythreyi Vattikuti, suresh kc


put something like in your jsp file
<%@ page language="java"%>
<%
//JSP Code
String name = request.getParameter("name");
if (name == null) {
    name = "no parameter passed";
}
%>
<script language="javascript">
var name;
name = "<%=name%>";
alert(name);
</script>
this will display the value of the name parameter that you pass to your jsp 
file. Of course, you can do something better with the variable, here I just 
use the alert function to display it back to user.
http://mundoguiadeviajes.blogspot.com/