Download - Output.doc

Transcript

Ridhima Bharti 12-MCA-2k13import java.io.*; import javax.servlet.*; import javax.servlet.http.*;import java.util.*;public class frm1 extends HttpServlet {

public void init(ServletConfig config)throws ServletException{ super.init(config);}

public void destroy(){ System.out.println(" Destroy method calling " );} public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { float Sum ; float Average; int w,x,y,z;

response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.println(""); out.println("Myname"); out.println("
" Welcome Student ""); out.println(""); out.println(""); out.println("
Ist Subject Marks: "+request.getParameter("1")+""); out.println("
2nd Subject Marks: "+request.getParameter("2")+""); out.println("
3rd Subject Marks: "+request.getParameter("3")+""); out.println("
4th Subject Marks: "+request.getParameter("4")+""); w=Integer.parseInt(request.getParameter("1")); x=Integer.parseInt(request.getParameter("2")); y=Integer.parseInt(request.getParameter("3")); z=Integer.parseInt(request.getParameter("4")); if((w=100)||(y=100)&&(x=100)&&(z=100)) {out.print("number must be between 0 t0 100");RequestDispatcher rd=request.getRequestDispatcher("studentdetail");rd.include(request,response); }else{ Sum=w+x+y+z; Average=Sum/4; out.println("
Toatl Obtain Marks: "+Sum+""); out.println("
Average of Marks: "+Average+"");} out.println(""); out.println(""); }

public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{ doGet(request,response);}

}