Assignment-5: Jsp:forward Action Tag
Assignment-5: Jsp:forward Action Tag
1907022
Assignment-5
● jsp:forward
● jsp:include
printdate.jsp
<html>
<body>
<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>
</body>
</html>
jsp:include action tag:
The jsp:include action tag is used to include the content of another resource it may be jsp, html
or servlet.
The jsp include action tag includes the resource at request time so it is better for dynamic pages
because there might be changes in future.
Syntax of jsp:include action tag without parameter
<jsp:include page="relativeURL | <%= expression %>" />
Example:
File: index.jsp
<h2>this is index page</h2>
<jsp:include page="printdate.jsp" />
<h2>end section of index page</h2>
File: printdate.jsp
<% out.print("Today is:"+java.util.Calendar.getInstance().getTime()); %>
Output:
Source Code:
<head>
</head>
<body>
<center>
</center>
<%
%>
</body>
</html>
Output:
3) Write a JSP program shows the Fibonacci series up to a particular term, while the input is taken
from an HTML form.
Source Code:
Input.html
<!DOCTYPE html>
<html>
<head>
<title>Fibonacci Series</title>
<style type="text/css">
body
margin: 0;
padding: 0;
background-color:#6abadeba;
font-family: 'Arial';
.login{
width: 382px;
overflow: hidden;
margin: auto;
margin: 20 0 0 450px;
padding: 80px;
background: #23463f;
border-radius: 15px ;
h2{
text-align: center;
color: #277582;
padding: 20px;
label{
color: #08ffd1;
font-size: 17px;
#Uname{
width: 300px;
height: 30px;
border: none;
border-radius: 3px;
padding-left: 8px;
#Pass{
width: 300px;
height: 30px;
border: none;
border-radius: 3px;
padding-left: 8px;
#log{
width: 300px;
height: 30px;
border: none;
border-radius: 17px;
padding-left: 7px;
color: blue;
}
span{
color: white;
font-size: 17px;
a{
float: right;
background-color: grey;
</style>
</head>
<body>
<h2>Fibonacci Series</h2><br>
<div class="login">
</b>
</label>
</form>
</div>
</body>
</html>
Factorial.jsp
<html>
<body>
<%!
int n;
String str;
int fibo(int n) {
if(n<2)
return n;
else
%>
<%
str = request.getParameter("val");
n = Integer.parseInt(str);
%>
</body>
</html>
Output:
4) Write a JSP program to get random value using math function and based on the input
from 1 to 7,weekdays need to be displayed.
Source Code:
<html>
<body>
<%
out.print(days[int1-1]);
%>
</body>
</html>
Output:
5) Write a sample JSP program for @page and @include
Index.jsp
<html>
<head>
<title>
Abis
</title>
</head>
<body>
</body>
</html>
Printdate.jsp
<%
out.print(days[int1-1]);
%>
Output: