Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


SuneelKumar Machha
jspboss
2 Answer(s)      3 years and 11 months ago
Posted in : JSP-Servlet


how do we pass multiple values with url in jsp


Advertisement
View Answers

January 13, 2011 at 12:36 PM


Hi Friend,

Try the following code:

1)form.jsp:

<html>
<script>
function passParam(){
    var name=document.form.name.value;
    var address=document.form.address.value;
    var f=document.form;
    f.action="url.jsp?name="+name+"&&address="+address;
    f.submit();
}
    </script>
<form name="form">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="button" value="submit" onclick="passParam();"></td></tr>
</table>
</html>

2)url.jsp:

<%
String name=request.getParameter("name");
String address=request.getParameter("address");
%>
Your name is: <%=name%> and address is: <%=address%>.

Thanks



January 13, 2011 at 12:36 PM


Hi Friend,

Try the following code:

1)form.jsp:

<html>
<script>
function passParam(){
    var name=document.form.name.value;
    var address=document.form.address.value;
    var f=document.form;
    f.action="url.jsp?name="+name+"&&address="+address;
    f.submit();
}
    </script>
<form name="form">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td></td><td><input type="button" value="submit" onclick="passParam();"></td></tr>
</table>
</html>

2)url.jsp:

<%
String name=request.getParameter("name");
String address=request.getParameter("address");
%>
Your name is: <%=name%> and address is: <%=address%>.

Thanks



Related Tutorials/Questions & Answers:
 

 

 

DMCA.com