User Section View Templates

User Section View Templates


Posted in : Spring Posted on : March 30, 2011 at 1:02 PM Comments : [ 0 ]

This section contains the User Section View Templates.

User Section View Templates

For handling view in the user section of the application, we use the following JSP files as view templates.  The code of each JSP file in the user directory of view directory is given below :

questionpaper.jsp

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2 align="center" >Question Paper</h2>
<hr width=600 >
<div align="right" style="top:0 " >
<%if(session.getAttribute("userName")!=null){ %>
Welcome :<% out.print(session.getAttribute("userName"));%>
<%} %>&nbsp;
<a href="logout.thml" >LogOut</a> 
</div>

<form:form action="questionpaper.thml" >
<table align="center" >
<core:if test="${!empty questionPaperList}"> 
<% int i=0; %>

<core:forEach var="questionPaperCommand" items="${questionPaperList}" >
<input type="hidden" name="question" /> 
<input type="hidden" value="${questionPaperCommand.questionId}" name="quesNum[<%=i%>]" /> 
<tr> 
<td>
<core:out value="<%=i+1%>"></core:out>
<core:out value="."></core:out>
<core:out value="Question :"></core:out>
<core:out value="${questionPaperCommand.question}"></core:out></td>
</tr>
<tr>
<td>
<input type="radio" name="option[<%=i%>]" value="${questionPaperCommand.option1Id}">
<core:out value="${questionPaperCommand.option1}"></core:out>
</td>
</tr>
<tr>
<td>
<input type="radio" name="option[<%=i%>]" value="${questionPaperCommand.option2Id}">
<core:out value="${questionPaperCommand.option2}"></core:out>
</td>
</tr>
<tr>
<td>
<input type="radio" name="option[<%=i%>]" value="${questionPaperCommand.option3Id}">
<core:out value="${questionPaperCommand.option3}"></core:out>
</td>
</tr>
<tr>
<td>
<input type="radio" name="option[<%=i%>]" value="${questionPaperCommand.option4Id}">
<core:out value="${questionPaperCommand.option4}"></core:out>
</td>
</tr>
<% i++; %> 
</core:forEach> 

<tr>
<td> 
<input type="submit" value="Submit" />
</td>
</tr>
</core:if> 
<core:if test="${empty questionPaperList}">
<tr>
<td>
<core:out value="Not Avaliable Any Question"></core:out>
</td> 
</tr>
</core:if> 
</table>
</form:form>

</body>
</html>

questionpaperresult.jsp

<%@taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2 align="center" >Paper Result </h2>
<hr width=600 >
<div align="right" style="top:0 " >
<%if(session.getAttribute("userName")!=null){ %>
Welcome :<% out.print(session.getAttribute("userName"));%>
<%} %>&nbsp;
<a href="logout.thml" >LogOut</a> 
</div>
<table align="center" >
<% int i=0; %>
<core:forEach var="questionPaperCommand" items="${questionPaperList}" >
<tr>
<td>
<core:out value="<%=i+1%>"></core:out>
<core:out value="."></core:out>
<core:out value="Question :"></core:out>
<core:out value="${questionPaperCommand.question}"></core:out></td>
</tr>
<tr> 
<td>
<font color="green" ><core:out value="Answer : "></core:out></font>
<core:out value="${questionPaperCommand.option1}"></core:out>
</tr>
<% i++; %> 
</core:forEach>
<tr>
<td colspan="2" ><core:out value="--------------------------------------"></core:out></td> 
</tr>
<tr>
<td><core:out value="Result"></core:out></td> 
</tr>
<tr>
<td colspan="2">
<core:out value="Total Question"></core:out>
<core:out value="${totalQuestion}"></core:out>
</td> 
</tr>
<tr>
<td colspan="2" >
<core:out value="Result Marks"></core:out>
<core:out value="${rightAnswer}"></core:out>
</td> 
</tr>
<tr>
<td colspan="2" >
<core:out value="Number of right answer : "></core:out>
<core:out value="${rightAnswer}"></core:out>
</td> 
</tr>
<tr>
<td colspan="2" >
<core:out value="Number of wrong answer : "></core:out>
<core:out value="${wongAnswer}"></core:out>
</td> 
</tr>
</table>
</body>
</html>

selectpaper.jsp

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2 align="center" >Select Paper</h2> 
<hr width=600 >
<div align="right" style="top:0 " >
<%if(session.getAttribute("userName")!=null){ %>
Welcome :<% out.print(session.getAttribute("userName"));%>
<%} %>&nbsp;
<a href="logout.thml" >LogOut</a> 
</div>
<form:form commandName="language" action="selectpaper.html" >
<table align="center" >
<tr>
<td>
Select Paper:
</td>
<td>
<form:select path="languageId">
<form:option label="--Select Language--" value="-1" />
<form:options items="${languagelist}" itemLabel="languageName" itemValue="languageId" /> 
</form:select> 
</td>
</tr>
<tr> 
<td></td>
<td><font color="red" ><core:out value="${errormessage}"></core:out></font></font> </td> 
</tr> 
<tr> 
<td></td>
<td><input type="submit" value="Submit" /></td> 
</tr> 
</table> 

</form:form>

</body>
</html>

userlogin.jsp

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1 align="center" >Online Test Application</h1>
<hr width=600 >
<form:form commandName="user" action="userlogin.html" >
<table align="center">
<tr>
<td><form:label path="userEmail" >User Email:</form:label></td>
<td>
<form:input path="userEmail"/> 
</td>
</tr>
<tr>
<td></td>
<td>
<FONT color="red"><form:errors path="userEmail"></form:errors></FONT>
</td>
</tr>
<tr>
<td><form:label path="password" >Password:</form:label></td>
<td>
<form:password path="password" /> 
</td>
</tr>
<tr>
<td></td>
<td>
<FONT color="red"><form:errors path="password"></form:errors></FONT>
</td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Login"/> or
<a href="userregistration.jsp"> Sign up</a>
</td>
</tr> 
</table>
</form:form> 

</body>
</html>

userregistration.jsp

<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2 align="center" >User Registration</h2>
<hr width=600 >
<form:form action="userregistration.html" commandName="userForm" >
<table align="center" >
<tr>
<td>
<form:label path="userName" >User Name:</form:label>
<FONT color="red"><form:errors path="userName" /></FONT>
</td>
<tr>
</tr> 
<td>
<form:input path="userName" size="26" /> 
</tr>
<tr>
<td>
<form:label path="userEmail">User Email:</form:label>
<FONT color="red"><form:errors path="userEmail" /></FONT>
</td>
<tr>
</tr> 
<td>
<form:input path="userEmail" size="26" />
</tr>
<tr>
<td>
<form:label path="password">Password:</form:label>
<FONT color="red"><form:errors path="password" /></FONT>
</td>
<tr>
</tr> 
<td>
<form:password path="password" size="26" />
</tr> 
<tr>
<td>
<form:label path="confirmPassword">Confirm Password:</form:label>
</td>
<tr>
</tr> 
<td>
<form:password path="confirmPassword" size="26" />
</tr>
</tr> 
<td>
<form:label path="userGender">Select Gender:</form:label>
<FONT color="red"><form:errors path="userGender" /></FONT>
</td> 
</tr>
</tr> 
<td>
<form:select path="userGender">
<form:option label="--Select Gender--" value="-1" />
<form:option label="Male" value="M" />
<form:option label="Female" value="F" /> 
</form:select>
</td> 
</tr> 
<tr>
<td>
<form:label path="phoneNo">phone No:</form:label>
<FONT color="red"><form:errors path="phoneNo" /></FONT>
</td>
<tr>
</tr> 
<td>
<form:input path="phoneNo" size="26" />
</tr>
<tr>
<td>
<form:label path="address">Address:</form:label>
</td>
<tr>
</tr> 
<td>
<form:textarea path="address" rows="5" ></form:textarea>
</tr> 
<tr> 
<td>
<input type="submit" value="Submit"/> 
</td>
</tr> 

</table>
</form:form>

</body>
</html>

Click here to go back to main page

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics