Você está na página 1de 9

Aim : Create application in jsp for all jsp component.

index.jsp

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Student information</title>
</head>
<body>
<FORM action="frst.jsp" method="post">
<table border="1" bgcolor="lightgrey" align="center">
<tr align="center">
<td colspan="2"><center> STUDENT INFORMATION </center> </td>
</tr>
<tr>
<td>Student name</td>
<td> <input type="text" name="name"> </td>
</tr>
<tr>
<td>Student Roll no.</td>
<td> <input type="text" name="no"> </td>
</tr>
<tr>
<td>Course</td>
<td> <input type="text" name="corse"> </td>
</tr>
<tr>
<td>Student year</td>
<td> <input type="text" name="year"> </td>
</tr>
<tr>
<td>Number of Book issued</td>
<td> <input type="text" name="book" onblur="javascript:if(this.value>'5'){alert('Can not
issue more than book');this.value='';this.focus();}"> </td>
</tr>
<tr>
<td>Institute</td>
<td> <input type="text" name="ins"> </td>
</tr>
<tr>
<td><input type="submit" name="submit"></td>
<td> <input type="reset" name="reset"> </td>
</tr>
</table>
</form>
</body>
</html>

footer.jsp

<%@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>
<table border="1" bgcolor="lightgrey" align="center">
<tr>
<td rowspan="2" colspan="2">
--- ---- ---- NCRD Sterling ---- ---- ---
</td>
</tr>
</table>
</body>
</html>

header.jsp

<%@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>
<table border="1" bgcolor="lightgrey" align="center">
<tr>
<td rowspan="2" colspan="2">
----- ---- Student Information ---- -----
</td>
</tr>
</table>
</body>
</html>
frst.jsp

<%@page import="java.text.DateFormat"%>
<%@page contentType="text/html" pageEncoding="UTF-8" import="java.text.SimpleDateFormat"
%>
<%@page import="java.util.*" %>
<%@include file="header.jsp" %>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>registration form</title>
</head>
<body>
<table border="1" bgcolor="lightgrey" align="center">
<tr>
<td>NAME :
</td>
<% String name1=request.getParameter("name"); %>
<td><input type="text" name="name" value='<%= name1%>' readonly="yes"></td>
</tr>
<tr>
<td>number :
</td>
<% String no1=request.getParameter("no"); %>
<td><input type="text" name="name" value='<%= no1%>' readonly="yes"></td>
</tr>
<tr>
<td>course :
</td>
<% String corse1=request.getParameter("corse"); %>
<td><input type="text" name="name" value='<%= corse1%>' readonly="yes"></td>
</tr>
<tr>
<td>year :
</td>
<% String year1=request.getParameter("year"); %>
<td><input type="text" name="name" value='<%= year1%>' readonly="yes"></td>
</tr>
<tr>
<td>Book issue :
</td>
<% Integer book1=Integer.parseInt(request.getParameter("book")); %>
<td><input type="text" name="name" value='<%= book1%>' readonly="yes"></td>
</tr>
<tr>
<td>Institute :
</td>
<% String ins1=request.getParameter("ins"); %>
<td><input type="text" name="name" value='<%= ins1%>' readonly="yes"></td>
</tr>
<tr>
<td>Current date :
</td>
<% DateFormat df = new SimpleDateFormat("yyyy/mm/dd hh:mm:ss"); %><% Date d=new
Date(); %>
<td><input type="text" name="name" value='<%= df.format(d)%>' readonly="yes"></td>
</tr>
<tr>

<td colspan="3"> <center><% if(book1<5){%>
Remaining books : <%= 5-book1 %> <%}%></center>
</td>
</tr>

</table>
</body>
</html>
<%@include file="footer.jsp" %>






Aim : Create a sample program to demonstrate JSP Syntax and Semantics.

index.jsp

<%@page import="java.util.*" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Echo</title>
<style>
<jsp:include page="style.css" flush="true" />
</style>
</head>

<body>
<h1>HTTP Request Headers Received..</h1>
<table border="1" cellpadding="4" cellspacing="0">
<%
Enumeration eNames = request.getHeaderNames();
while(eNames.hasMoreElements()){
String name = (String) eNames.nextElement();
String value= normalize(request.getHeader(name));
%>
<tr><td><%=name%></td><td><%=value %></td></tr>
<%
}
%>
</table>
</body>
</html>
<%!
private String normalize(String value)
{
StringBuffer sb= new StringBuffer();
for(int i=0; i<value.length();i++){
char c = value.charAt(i);
sb.append(c);
if(c == ';')
sb.append("<br>");
}
return sb.toString();
}
%>





style.css

body{
font: Sans-Serif 12px;
background-color: #FEFEF2;
};
h1 { font-size: 130% }

Você também pode gostar