<html>
<head>
<title>Using Multiple Forms</title>
</head>
<body>
<h1>Using Multiple Forms</h1>
<%
if(request.getParameter("button") != null) {
%>
<% String s = request.getParameter("button");
int no1,no2;
if(request.getParameter("no1").equals("")) { no1 = 0; } else no1 = Integer.valueOf(request.getParameter("no1"));
if(request.getParameter("no2").equals("")) { no2 = 0; } else no2 = Integer.valueOf(request.getParameter("no2"));
if (s.equals("ADD")) {
out.println("Result is " + (no1 + no2));
}
else if (s.equals("SUB")) {
out.println("Result is " + (no1-no2));
}
else if(s.equals("MUL")) {
out.println("Result is " + (no1*no2));
}
else if(s.equals("DIV")) {
out.println("Result is " + (no1/no2));
}
%>
<%
}
%>
<form name="form1" method="get">
<input name="no1">
<input name="no2">
<input type="hidden" name="button" value="ADD">
<input type="submit" value="ADD">
</form>
<form name="form2" method="get">
<input name="no1">
<input name="no2">
<input type="hidden" name="button" value="SUB">
<input type="submit" value="SUB">
</form>
<form name="form3" method="get">
<input name="no1">
<input name="no2">
<input type="hidden" name="button" value="MUL">
<input type="submit" value="MUL">
</form>
<form name="form4" method="get">
<input name="no1">
<input name="no2">
<input type="hidden" name="button" value="DIV">
<input type="submit" value="DIV">
</form>
</body>
</html>
Raj...
Chat with our AI personalities
You can set the value in the hidden form fields using javascript and access the form fields in JSP
You cannot. You display JSP Pages using the help of Servlets. Servlets are of the background classes and you cannot display them
JSP actions are XML tags that direct the server to use existing components or control the behavior of the JSP engine. JSP Actions consist of a typical (XML-based) prefix of "jsp" followed by a colon, followed by the action name followed by one or more attribute parameters. There are six JSP Actions: < jsp : include / > < jsp : forward / > < jsp : plugin / > < jsp : usebean / > < jsp : setProperty / > < jsp : getProperty / >
jsp means Java Server Pages.
The implicit objects in a JSP page are:requestresponsepageContextsessionapplicationoutconfigpage