Write a jsp program to print range of Fibonacci Series
i)index.html
<%@page
contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta
http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Enter the Limit of Fibonacci
Series</h1>
<form
action="fibo.jsp">
Enter the Number:<input
type="text" name="n1"/><br/>
<input type="submit"
value="Enter"/>
</form>
</body>
</html>
ii) fibo.jsp
<html>
<head>
<meta
http-equiv="Content-Type" content="text/html;
charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>The Value of Fibonacci
Series</h1>
<h1>
<%
String
s=request.getParameter("n1");
int n=Integer.parseInt(s);
int i=1,f1=0,f2=1,f3;
while(i<=n)
{
out.println(f1);
f3=f1+f2;
f1=f2;
f2=f3;
i=i+1;
}
%>
</h1>
</body>
</html>
No comments:
Post a Comment