answersLogoWhite

0

<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...

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Can you write method in JSP scriptlet?

Yes, you can.


Describe jsp processing?

JSPs are converted to servlets before the container runs them. This is actually cool because you don't need hardcore java programming skills to create a JSP page whereas you'll need them to write a servlet. Moreover, all you'll need to write a JSP is some expertise in creating HTML files and in using JavaScript. You can create front-end JSP pages without having much expertise in Java at all. Although JSP reduces the required skill level, JSP becomes a servlet, with the nice performance and portability benefits.


Write a JSP program which displays webpage containing arrival of new items within a particular month in the different branches of a retail company?

vbcvbvbvcbc vbcvbvbvcbc


How validate and retrieve data from database in jsp?

We can do validation by using JavaScript. Here we are using function Validate(). Iam creating one JSP name index.jsp &amp; give a link to another JSP name basic.jsp. In that Jsp iam using Type 1 Jdbc Driver &amp; giving a database connection


How the data is viewed in a JSP in the form of table?

You can display data in Tabular format in a JSP page using the HTML &lt;Table&gt; Tag. You can even assign dynamic values to the table using JSP Scriptlets. &lt;% %&gt;


Can you create web forums using jsp and servlets?

Yes. All sorts of web Applications/websites can be created using JSP and Servlets


How do you create chart using ireport in jsp?

you die.


How do we find a jsp version in Java?

first you have to find out what version of j2ee you are using then from there you can lookup the jsp version for that version of j2ee


How do you transfer values from javascript to JSP?

You can set the value in the hidden form fields using javascript and access the form fields in JSP


Create a table using JSP Servlets?

scope of operater


Is jsp a language.justify?

JSP stands for Java Server Page, which is a program that controls how things appear on a webpage. JSP is not considered a language but it is written for programs using the programming language of JavaScript.


Which one is faster servlet OR jsp?

Servlet is more faster than JSP, but JSP is more convenient than Servlet and JSP is clearly superior, shorter, simple and easier to use. JSP can be perceived as Java in HTML code. JSP require no explicit compilation as like servlets and can keep in the web application server as HTML file. The web application server in turn compile the java code in JSP and load it in its library for future execution. Servlet can be perceived as HTML in Java code. The servlet is the class file, which would be loaded in the web application server as a program. The program output will be directed to the outstream object which in turn direct to the client as HTML elements.