calc.html
<html>
<body>
<form action="ac">
First Value
<input type="text" name="fv"><br>
Second Value
<input type="text" name="sv"><br>
<input type="submit" name="check" value="Check"/>
<br>
<input type="radio" name="Ath" value="add">ADD<br>
<input type="radio" name="Ath" value="sub">SUB<br>
<input type="radio" name="Ath" value="mul">MUL<br>
<input type="radio" name="Ath" value="div">DIV<br>
</form>
</body>
</html>
ArrithBeanDemo.java
package mybean;
public class ArrithBeanDemo
{
int fv,sv;
public void setFvalue(int fv)
{
this.fv=fv;
}
public void setSvalue(int sv)
{
this.sv=sv;
}
public int getFvalue()
{
return fv;
}
public int getSvalue()
{
return sv;
}
}
ArrithControal.java
package controal;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import model.*;
public class ArrithControal extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
int a=0;
int fv= Integer.parseInt(req.getParameter("fv"));
int sv= Integer.parseInt(req.getParameter("sv"));
String add= req.getParameter("Ath");
ArrithModel am= new ArrithModel(fv,sv);
if(add.equals("add"))
{
a=am.Add();
}
else if(add.equals("sub"))
{
a=am.Sub();
}
else if(add.equals("mul"))
{
a=am.Mul();
}
else if(add.equals("div"))
{
a=am.Div();
}
req.setAttribute("key",a);
RequestDispatcher rd=req.getRequestDispatcher("/WEB-INF/result.jsp");
rd.forward(req,res);
}
}
ExamResultBean.java
package mybean;
public class ExamResultBean
{
String fn="";
int en,mis,fon,dc,or,wtad,tot,per;
String s="";
public String result(int s1,int s2,int s3,int s4,int s5)
{
tot=s1+s2+s3+s4+s5;
per=(tot/5)*100;
if(s1<35 && s2<35 && s3<35 && s4<35 && s5<35)
{
return "You Are fail ";
}
else if(per>35 && per<=50)
{
return "Yor are Pass ";
}
else if(per>50 && per<=60)
{
return "Yor are get Second class ";
}
else if(per>60 && per<=70)
{
return "Yor are get First class ";
}
else
{
return "Yor are get Distriction ";
}
}
public void setEno(int en)
{
this.en=en;
}
public int getEno()
{
return en;
}
public void setFname(String fn)
{
this.fn=fn;
}
public String getFname()
{
return fn;
}
public void setSubfon(int fon)
{
this.fon=fon;
}
public int getSubfon()
{
return fon;
}
public void setSubor(int or)
{
this.or=or;
}
public int getSubor()
{
return or;
}
public void setSubmis(int mis)
{
this.mis=mis;
}
public int getSubmis()
{
return mis;
}
public void setSubdc(int dc)
{
this.dc=dc;
}
public int getSubdc()
{
return dc;
}
public void setSubwtad(int wtad)
{
this.wtad=wtad;
}
public int getSubwtad()
{
return wtad;
}
}
result.jsp
<%
int a=(int)request.getAttribute("key");
out.print(a);
%>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>ArrithControal</servlet-name>
<servlet-class>controal.ArrithControal</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ArrithControal</servlet-name>
<url-pattern>/ac</url-pattern>
</servlet-mapping>
</web-app>
<html>
<body>
<form action="ac">
First Value
<input type="text" name="fv"><br>
Second Value
<input type="text" name="sv"><br>
<input type="submit" name="check" value="Check"/>
<br>
<input type="radio" name="Ath" value="add">ADD<br>
<input type="radio" name="Ath" value="sub">SUB<br>
<input type="radio" name="Ath" value="mul">MUL<br>
<input type="radio" name="Ath" value="div">DIV<br>
</form>
</body>
</html>
ArrithBeanDemo.java
package mybean;
public class ArrithBeanDemo
{
int fv,sv;
public void setFvalue(int fv)
{
this.fv=fv;
}
public void setSvalue(int sv)
{
this.sv=sv;
}
public int getFvalue()
{
return fv;
}
public int getSvalue()
{
return sv;
}
}
ArrithControal.java
package controal;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import model.*;
public class ArrithControal extends HttpServlet
{
public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
{
int a=0;
int fv= Integer.parseInt(req.getParameter("fv"));
int sv= Integer.parseInt(req.getParameter("sv"));
String add= req.getParameter("Ath");
ArrithModel am= new ArrithModel(fv,sv);
if(add.equals("add"))
{
a=am.Add();
}
else if(add.equals("sub"))
{
a=am.Sub();
}
else if(add.equals("mul"))
{
a=am.Mul();
}
else if(add.equals("div"))
{
a=am.Div();
}
req.setAttribute("key",a);
RequestDispatcher rd=req.getRequestDispatcher("/WEB-INF/result.jsp");
rd.forward(req,res);
}
}
ExamResultBean.java
package mybean;
public class ExamResultBean
{
String fn="";
int en,mis,fon,dc,or,wtad,tot,per;
String s="";
public String result(int s1,int s2,int s3,int s4,int s5)
{
tot=s1+s2+s3+s4+s5;
per=(tot/5)*100;
if(s1<35 && s2<35 && s3<35 && s4<35 && s5<35)
{
return "You Are fail ";
}
else if(per>35 && per<=50)
{
return "Yor are Pass ";
}
else if(per>50 && per<=60)
{
return "Yor are get Second class ";
}
else if(per>60 && per<=70)
{
return "Yor are get First class ";
}
else
{
return "Yor are get Distriction ";
}
}
public void setEno(int en)
{
this.en=en;
}
public int getEno()
{
return en;
}
public void setFname(String fn)
{
this.fn=fn;
}
public String getFname()
{
return fn;
}
public void setSubfon(int fon)
{
this.fon=fon;
}
public int getSubfon()
{
return fon;
}
public void setSubor(int or)
{
this.or=or;
}
public int getSubor()
{
return or;
}
public void setSubmis(int mis)
{
this.mis=mis;
}
public int getSubmis()
{
return mis;
}
public void setSubdc(int dc)
{
this.dc=dc;
}
public int getSubdc()
{
return dc;
}
public void setSubwtad(int wtad)
{
this.wtad=wtad;
}
public int getSubwtad()
{
return wtad;
}
}
result.jsp
<%
int a=(int)request.getAttribute("key");
out.print(a);
%>
web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<servlet>
<servlet-name>ArrithControal</servlet-name>
<servlet-class>controal.ArrithControal</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ArrithControal</servlet-name>
<url-pattern>/ac</url-pattern>
</servlet-mapping>
</web-app>
No comments:
Post a Comment