HTML FILE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<form method="POST" action="http://localhost:8080/ZWebApp/calc">
Enter First Number : <input type="text" name="first">
<br><br><br>
Select Operator : <input type="radio" name="operator" value="add" selected=true>+ <input type="radio" name="operator" value="sub">- <input type="radio" name="operator" value="mul">* <input type="radio" name="operator" value="div">/ <input type="radio" name="operator" value="mod">%
<br><br><br>
Enter Second Number : <input type="text" name="second">
<br><br><br>
<input type="submit" value="Perform Operation">
</form>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<form method="POST" action="http://localhost:8080/ZWebApp/calc">
Enter First Number : <input type="text" name="first">
<br><br><br>
Select Operator : <input type="radio" name="operator" value="add" selected=true>+ <input type="radio" name="operator" value="sub">- <input type="radio" name="operator" value="mul">* <input type="radio" name="operator" value="div">/ <input type="radio" name="operator" value="mod">%
<br><br><br>
Enter Second Number : <input type="text" name="second">
<br><br><br>
<input type="submit" value="Perform Operation">
</form>
</body>
</html>
SERVLET FILE
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class Calculator extends HttpServlet
{
public void init(ServletConfig config) throws ServletException
{
super.init(config);
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException
{
PrintWriter pw;
response.setContentType("text/html");
pw=response.getWriter();
int num1=Integer.parseInt(request.getParameter("first"));
int num2=Integer.parseInt(request.getParameter("second"));
String operator=request.getParameter("operator");
pw.println("<html><body>");
if (operator.equals("add"))
{
pw.println(""+num1+" + "+num2+" = "+(num1+num2));
}
else if (operator.equals("sub"))
{
pw.println(""+num1+" - "+num2+" = "+(num1-num2));
}
else if (operator.equals("mul"))
{
pw.println(""+num1+" * "+num2+" = "+(num1*num2));
}
else if (operator.equals("div"))
{
pw.println(""+num1+" / "+num2+" = "+(num1/num2));
}
else
{
pw.println(""+num1+" % "+num2+" = "+(num1%num2));
}
pw.println("</body></html>");
pw.close();
}
}
I liked your blog.Thanks for your interest in sharing your ideas.keep doing more.
ReplyDeleteEnglish Speaking Classes in Mumbai
English Speaking Course in Mumbai
Best English Speaking Classes in Mumbai
Spoken English Classes in Mumbai
English Classes in Mumbai
Spoken English in Chennai
Spoken English Class in Chennai
Such a wonderful post, Your explanation way is too good and this is very easy to understand with depth content. Kindly updating for me.
ReplyDeleteCorporate Training in Chennai
Corporate Training
Power BI Training in Chennai
Excel Training in Chennai
Linux Training in Chennai
Unix Training in Chennai
Tableau Training in Chennai
Oracle Training in Chennai
Pega Training in Chennai
Oracle DBA Training in Chennai
youtubers life apk
ReplyDeletenews whatsapp groups
ReplyDeleteAwesome News .
ReplyDeletemedical coding course in chennai
medical coding institute in chennai
Air Hostess Course in Chennai
cpc training in chennai
cpc certification training in chennai
medical coding institute in chennai
medical coding training center in chennai
Yes these codes are really helpful for newcomers as well as experts. They save alot of time as well.
ReplyDeleteHere is the site for recent report of the various codes and their compilations.
Delete
ReplyDeleteHave you ever tried GBWhatsapp Apk, which is the Mod version of its original server which is not available on play store but you can play it by clicking here.
mmorpg
ReplyDeleteinstagram takipçi satın al
tiktok jeton hilesi
tiktok jeton hilesi
Saç ekimi antalya
referans kimliği nedir
İnstagram Takipçi Satın Al
Metin pvp
instagram takipçi satın al
PERDE MODELLERİ
ReplyDeleteMobil Onay
TÜRK TELEKOM MOBİL ÖDEME BOZDURMA
Nft nasıl alinir
Ankara Evden Eve Nakliyat
trafik sigortasi
dedektör
web sitesi kurma
aşk kitapları
Download Adobe FrameMaker 2022 Full Crack is a complete solution to create, enrich, manage and publish technical documentation.https://crackdj.com/adobe-framemaker-crack/
ReplyDelete“I love you more than anyone else in this world because you know me the best and you understand me the most…. Always stay the same.” I love you Day Wishes .
ReplyDeleteI Love You messages For Him
I appreciate you expanding my knowledge. You are a fantastic writer. Your writing is clear and quite helpful.
ReplyDeletePTE Coaching in Vadodara
Thanks for the blog. It was helpful.
ReplyDeleteJava training in Pune
Just a quick tip: consider adding more examples of https://apktodo.io/ to enhance understanding. Keep it up!
ReplyDelete