How to call Jsp page from Javascript?

We can call JSP page from JavaScript using the property window.location.href.

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>

Note:

“window.location.href = ‘download.jsp’?name=john;” where download.jsp is jsp file, name is parameter name and john is parameter value.

hello.jsp:

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

Share

No related posts.

Tags: , ,
Technical, , Permalink

Leave a Reply

Your email address will not be published. Required fields are marked *

*


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>