Sixth Lesson on JSP
Now we are going to create a jsp page to find out area and circumference of a circle. In the first html page the user will give the radius and corresponding JSP page will calculate all operations. The front page will be like ::
The Code For this page ::
<%--
Document : index
Created on : 01 Nov, 2012, 7:35:11 AM
Author : nested code team
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page | Calculate Area</title>
</head>
<body><br><br><center><h1>Works on Circle</h1>
<form action="circle.jsp ">
<h2>Enter the Radius :: <input type=text name=n ><br><br>
<input type=submit value="Submit"></h2>
</form></center>
</body>
</html>
Document : index
Created on : 01 Nov, 2012, 7:35:11 AM
Author : nested code team
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page | Calculate Area</title>
</head>
<body><br><br><center><h1>Works on Circle</h1>
<form action="circle.jsp ">
<h2>Enter the Radius :: <input type=text name=n ><br><br>
<input type=submit value="Submit"></h2>
</form></center>
</body>
</html>
Now we have to create the "circle.jsp" page . The code for this page ::
<%--
Document : circle
Created on : 1 Nov, 2012, 12:25:11 PM
Author : ABHIK
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<center>
<h1>Results On Circle Are ::</h1>
<%
String ns= request.getParameter("n");
int n=Integer.parseInt(ns);
out.println("<pre>");
out.println("The radious of the circle= "+n);
double area=n*n*3.14;
double c=2*3.14*n;
out.println("The area of the Circle= "+area);
out.println("The Circumference of the circle= "+c);
out.println("</pre>");
%>
</center>
</body>
</html>
Document : circle
Created on : 1 Nov, 2012, 12:25:11 PM
Author : ABHIK
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<center>
<h1>Results On Circle Are ::</h1>
<%
String ns= request.getParameter("n");
int n=Integer.parseInt(ns);
out.println("<pre>");
out.println("The radious of the circle= "+n);
double area=n*n*3.14;
double c=2*3.14*n;
out.println("The area of the Circle= "+area);
out.println("The Circumference of the circle= "+c);
out.println("</pre>");
%>
</center>
</body>
</html>
Output ::
No comments:
Post a Comment