Posts Tagged ‘how to calljsp page from JS’

How to call Jsp page from Javascript?

Wednesday, July 1st, 2009

We can call JSP page from JavaScript using “window.location.href = ‘download.jsp’?name=john;” where download.jsp is jsp file, name is parameter name and john is parameter value.

Example:

Hello.html:

<html>
<head>
<title>Add Faulty Phones</title>
<script type=”text/javascript”>
function changeLocation()
{
window.location.href =’hello.jsp?name=John’;
}
</script>
</head>
<body>
<form method=get>
<INPUT TYPE=BUTTON ONCLICK=”changeLocation()” VALUE=”Click”>
</form>
</html>

 hello.jsp:

 <center>Hello <%=requset.getParameter(”name”)%>
</center>