my codes as below
user registration.jsp < jsp user view to get input >
{code}
<?xml version="1.0" encoding ="UTF-8"?>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html>
<head>
<title>Registeres USers Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<%--debugging code--%>
<%@ include file="debug.jsp" %>
<table width="1049" cellpadding="5" align="center">
<tr>
<td width="2378"><div align="center">
<h2 align="center"> User Registration</h2>
<p>
<c:url var="HmePgeURL" value="/cw/router/home" scope="page"/>
<a href="${HmePgeURL}">Home</a> <c:url var='BSPgeURL' value='/cw/router/login' scope='page'/>
<a href="${BSPgeURL}">Buy or Sell</a>
</p>
</div></td>
</tr>
</table>
<p align="center"> </p>
<p>This website is only open to members of the De MontFort University.
You will need a current @learner.dmu.ac.uk e-mail address in order to register.</p>
<p> If you've already registered for one site you do not need to register again </p>
<c:url value="/cw/router/userregistration" var="UregPgeURL" scope="page"/>
<form name="frmregister" method="post" action="${UregPgeURL}">
<div>
<table width="726" height="285" border="0" align="left" cellpadding="2" cellspacing="0">
<tr>
<td width="157" align="right" >Name:</td>
<td width="561" > <input name="txtname" type="text" value="${param.txtname}"/> </td>
</tr>
<c:if test="${!empty requestScope.reqInvalidUserName}">
<cut value="${requestScope.reqInvalidUserName}"/>
</c:if>
<tr>
<td width="157" align="right" >Department</td>
<td align="left" >
<select name="txtdepartment" value="${param.txtdepartment}" >
<option></option>
<option value="Faculty of Art and Design">Faculty of Art and Design</option>
<option value="Faculty of Business and Law">Faculty of Business and Law</option>
<option value="Faculty of Computing Sciences and Engineering">Faculty of Computing Sciences and Engineering</option>
<option value="Faculty of Health and Life Sciences">Faculty of Health and Life Sciences</option>
<option value="Faculty of Humanities">Faculty of Humanities</option>
</select>
</td>
</tr>
<tr>
<td align="right" >Programme</td>
<td ><input type="text" name="txtprogramme" value="${param.txtprogramme}" />
(eg: BIS,SE) </td>
</tr>
<tr>
<td align="right" >Telephone Number: </td>
<td ><input name="txtphonenum" type="text" value="${param.txtphonenum}" /></td>
</tr>
<tr>
<td align="right" >Date Of Birth: </td>
<td ><input name="txtday" type="text" size="15" value="${param.txtdob}" />(of format YYYY-MM-DD)</td>
</tr>
<tr>
<td align="right" >Username</td>
<td align="left" >
<input name="txtuserid" type="text" size="15" value="${param.txtuserid}" />
(eg. p07269027 from P07269027@learner.dmu.ac.uk)</td>
<c:if test="${!empty requestScope.reqInvalidUserId}">
<cut value="${requestScope.reqInvalidUserId}"/>
</c:if>
</tr>
<tr>
<td align="right" >Password</td>
<td align="left" >
<input name="txtpassword" type="password" size="15" value="${param.txtpassword}" />
</td></tr>
<c:if test="${!empty requestScope.reqInvalidPassword}">
<cut value="${requestScope.reqInvalidPassword}"/>
</c:if>
<tr>
<td align="right" >Confirm Password </td>
<td align="left" >
<input name="txtpasswordconf" type="password" size="15" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="frmsubmit" type="submit" value="Register User" />
<input type="reset" name="Reset" value="Reset" />
</td>
</tr>
</table>
<c:if test="${!empty requestScope.reqQueryErrorMessage}">
<cut value="${requestScope.reqQueryErrorMessage}"/>
</c:if>
<c:if test="${!empty requestScope.reqInvalidUpdate}">
<cut value="${requestScope.reqInvalidUpdate}"/>
</c:if>
</div>
</form>
</body>
</html>
{code}
{code} proregistration.jsp ( registration process jsp)
<?xml version="1.0" encoding ="UTF-8"?>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<%-- \WEB-INF\jsp\cwjsps\probooksforsale.jsp --%>
<%-- Probookforsale --%>
<%-- skip field validation and provide blankpage if first time in --%>
<c:if test="${empty param.frmsubmit}">
<c:set var="reqOutcome" scope="request" value=" "/>
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- initial request --%>
</c:if>
<%-- validate txtname --%>
<c:if test="${empty param.txtname}">
<c:set var="reqInvalidUserName" scope="request" value= "User Name Cannot Be Empty"/>
</c:if>
<%-- validate txtuserid --%>
<c:if test="${empty param.txtuserid}">
<c:set var="reqInvalidUserId" scope="request" value= "User ID Cannot Be Empty"/>
</c:if>
<%-- validate txtpassword--%>
<c:if test="${empty param.txtpassword}">
<c:set var="reqInvalidPassword" scope="request" value= "Password Cannot Be Empty"/>
</c:if>
<%-- if userid invalid or username invalid --%>
<%-- redisplay form with originl typed-in data and with errors marked --%>
<c:if test="${empty param.txtname or empty param.txtuserid}">
<c:set var="reqOutcome" scope="request" value= "failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
</c:if>
<c:catch var="pgeQueryError">
<sql:update var="pgeRowCount" scope="page" >
<%-- insert details to trader table --%>
INSERT INTO trader(dbTraderName,dbTraderDepartment,dbTraderProgramme,dbTraderPhoneNum ,dbTraderDOB,dbTraderPNumber,dbTraderPwd)
VALUES(?,?,?,?,?,?,?)
<sqlaram value="${param.txtname}"/>
<sqlaram value="${param.txtdepartment}"/>
<sqlaram value="${param.txtprogramme}"/>
<sqlaram value="${param.txtphonenum}"/>
<sqlaram value="${param.txtdob}"/>
<sqlaram value="${param.txtuserid}"/>
<sqlaram value="${param.txtpassword}"/>
</sql:update>
</c:catch>
<%-- check For query Error --%>
<c:if test="${not empty pgeQueryError}">
<c:choose>
<%-- check duplicate record --%>
<c:when test="${pgeQueryError.rootCause.errorCode =='1062'}">
<c:set var="reqQueryErrorMessage" scope="request" value="User already Registered - Duplicate Record" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/>
</c:when>
<ctherwise>
<%-- database error --%>
<c:set var="reqQueryErrorMessage" scope="request" value="Database Error" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
</ctherwise>
</c:choose>
<c:set var="reqOutcome" scope="request" value="failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
</c:if>
<%-- check For no rows returned --%>
<c:if test="${pgeRowCount !=1}">
<c:set var="reqInvalidUpdate" scope="request" value="*** rowCount not = 1"/>
<c:set var="reqOutcome" scope="request" value="failure"/>
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
</c:if>
<%-- Otherwise --%>
<%-- Outcome is success --%>
<c:if test="${pgeRowCount ==1}">
<c:set var="reqOutcome" scope="request" value="success" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/> <%-- success --%>
</c:if>
{code}
{code} router.jsp ( maps the jsp page based on success and failure)
<?xml version="1.0" encoding ="iso-8859-1"?>
<%-- /WEB-INF/jsp/cwjsps/router.jsp --%>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<%-- setup session if one does not exist --%>
<%@ page session="true" %>
<%-- set up debug variable --%>
<c:set var="sessDebug" scope="session" value="true"/>
<%-- get pathinfo information from the request --%>
<%-- this defines which use case has been requested --%>
<c:set var="pgePathInfo" scope="page" value="${pageContext.request.pathInfo}" />
<%-- uc02 : Login --%>
<c:if test="${pageScope.pgePathInfo =='/home'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>
</c:if>
<c:if test="${pageScope.pgePathInfo =='/login'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/prologin.jsp"/>
</c:if>
<%-- uc01 : View Details Of Books For Sale --%>
<c:if test="${pageScope.pgePathInfo =='/viewbooksforsale'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/probooksforsale.jsp"/>
</c:if>
<%-- uc01 : process User registration--%>
<c:if test="${pageScope.pgePathInfo =='/userregistration'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/proregistration.jsp"/>
</c:if>
<%-- uc01 : debug --%>
<c:if test="${pageScope.pgePathInfo =='/debug'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/debug.jsp"/>
</c:if>
<%-- uc01 : view Traders Own View --%>
<c:if test="${pageScope.pgePathInfo =='/Traderhomepage'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/Traderhomepage.jsp"/>
</c:if>
<%-- otherwise --%>
<jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>
user registration.jsp < jsp user view to get input >
{code}
<?xml version="1.0" encoding ="UTF-8"?>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html>
<head>
<title>Registeres USers Login Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<body>
<%--debugging code--%>
<%@ include file="debug.jsp" %>
<table width="1049" cellpadding="5" align="center">
<tr>
<td width="2378"><div align="center">
<h2 align="center"> User Registration</h2>
<p>
<c:url var="HmePgeURL" value="/cw/router/home" scope="page"/>
<a href="${HmePgeURL}">Home</a> <c:url var='BSPgeURL' value='/cw/router/login' scope='page'/>
<a href="${BSPgeURL}">Buy or Sell</a>
</p>
</div></td>
</tr>
</table>
<p align="center"> </p>
<p>This website is only open to members of the De MontFort University.
You will need a current @learner.dmu.ac.uk e-mail address in order to register.</p>
<p> If you've already registered for one site you do not need to register again </p>
<c:url value="/cw/router/userregistration" var="UregPgeURL" scope="page"/>
<form name="frmregister" method="post" action="${UregPgeURL}">
<div>
<table width="726" height="285" border="0" align="left" cellpadding="2" cellspacing="0">
<tr>
<td width="157" align="right" >Name:</td>
<td width="561" > <input name="txtname" type="text" value="${param.txtname}"/> </td>
</tr>
<c:if test="${!empty requestScope.reqInvalidUserName}">
<cut value="${requestScope.reqInvalidUserName}"/>
</c:if>
<tr>
<td width="157" align="right" >Department</td>
<td align="left" >
<select name="txtdepartment" value="${param.txtdepartment}" >
<option></option>
<option value="Faculty of Art and Design">Faculty of Art and Design</option>
<option value="Faculty of Business and Law">Faculty of Business and Law</option>
<option value="Faculty of Computing Sciences and Engineering">Faculty of Computing Sciences and Engineering</option>
<option value="Faculty of Health and Life Sciences">Faculty of Health and Life Sciences</option>
<option value="Faculty of Humanities">Faculty of Humanities</option>
</select>
</td>
</tr>
<tr>
<td align="right" >Programme</td>
<td ><input type="text" name="txtprogramme" value="${param.txtprogramme}" />
(eg: BIS,SE) </td>
</tr>
<tr>
<td align="right" >Telephone Number: </td>
<td ><input name="txtphonenum" type="text" value="${param.txtphonenum}" /></td>
</tr>
<tr>
<td align="right" >Date Of Birth: </td>
<td ><input name="txtday" type="text" size="15" value="${param.txtdob}" />(of format YYYY-MM-DD)</td>
</tr>
<tr>
<td align="right" >Username</td>
<td align="left" >
<input name="txtuserid" type="text" size="15" value="${param.txtuserid}" />
(eg. p07269027 from P07269027@learner.dmu.ac.uk)</td>
<c:if test="${!empty requestScope.reqInvalidUserId}">
<cut value="${requestScope.reqInvalidUserId}"/>
</c:if>
</tr>
<tr>
<td align="right" >Password</td>
<td align="left" >
<input name="txtpassword" type="password" size="15" value="${param.txtpassword}" />
</td></tr>
<c:if test="${!empty requestScope.reqInvalidPassword}">
<cut value="${requestScope.reqInvalidPassword}"/>
</c:if>
<tr>
<td align="right" >Confirm Password </td>
<td align="left" >
<input name="txtpasswordconf" type="password" size="15" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input name="frmsubmit" type="submit" value="Register User" />
<input type="reset" name="Reset" value="Reset" />
</td>
</tr>
</table>
<c:if test="${!empty requestScope.reqQueryErrorMessage}">
<cut value="${requestScope.reqQueryErrorMessage}"/>
</c:if>
<c:if test="${!empty requestScope.reqInvalidUpdate}">
<cut value="${requestScope.reqInvalidUpdate}"/>
</c:if>
</div>
</form>
</body>
</html>
{code}
{code} proregistration.jsp ( registration process jsp)
<?xml version="1.0" encoding ="UTF-8"?>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<%-- \WEB-INF\jsp\cwjsps\probooksforsale.jsp --%>
<%-- Probookforsale --%>
<%-- skip field validation and provide blankpage if first time in --%>
<c:if test="${empty param.frmsubmit}">
<c:set var="reqOutcome" scope="request" value=" "/>
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- initial request --%>
</c:if>
<%-- validate txtname --%>
<c:if test="${empty param.txtname}">
<c:set var="reqInvalidUserName" scope="request" value= "User Name Cannot Be Empty"/>
</c:if>
<%-- validate txtuserid --%>
<c:if test="${empty param.txtuserid}">
<c:set var="reqInvalidUserId" scope="request" value= "User ID Cannot Be Empty"/>
</c:if>
<%-- validate txtpassword--%>
<c:if test="${empty param.txtpassword}">
<c:set var="reqInvalidPassword" scope="request" value= "Password Cannot Be Empty"/>
</c:if>
<%-- if userid invalid or username invalid --%>
<%-- redisplay form with originl typed-in data and with errors marked --%>
<c:if test="${empty param.txtname or empty param.txtuserid}">
<c:set var="reqOutcome" scope="request" value= "failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
</c:if>
<c:catch var="pgeQueryError">
<sql:update var="pgeRowCount" scope="page" >
<%-- insert details to trader table --%>
INSERT INTO trader(dbTraderName,dbTraderDepartment,dbTraderProgramme,dbTraderPhoneNum ,dbTraderDOB,dbTraderPNumber,dbTraderPwd)
VALUES(?,?,?,?,?,?,?)
<sqlaram value="${param.txtname}"/>
<sqlaram value="${param.txtdepartment}"/>
<sqlaram value="${param.txtprogramme}"/>
<sqlaram value="${param.txtphonenum}"/>
<sqlaram value="${param.txtdob}"/>
<sqlaram value="${param.txtuserid}"/>
<sqlaram value="${param.txtpassword}"/>
</sql:update>
</c:catch>
<%-- check For query Error --%>
<c:if test="${not empty pgeQueryError}">
<c:choose>
<%-- check duplicate record --%>
<c:when test="${pgeQueryError.rootCause.errorCode =='1062'}">
<c:set var="reqQueryErrorMessage" scope="request" value="User already Registered - Duplicate Record" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/>
</c:when>
<ctherwise>
<%-- database error --%>
<c:set var="reqQueryErrorMessage" scope="request" value="Database Error" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
</ctherwise>
</c:choose>
<c:set var="reqOutcome" scope="request" value="failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
</c:if>
<%-- check For no rows returned --%>
<c:if test="${pgeRowCount !=1}">
<c:set var="reqInvalidUpdate" scope="request" value="*** rowCount not = 1"/>
<c:set var="reqOutcome" scope="request" value="failure"/>
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
</c:if>
<%-- Otherwise --%>
<%-- Outcome is success --%>
<c:if test="${pgeRowCount ==1}">
<c:set var="reqOutcome" scope="request" value="success" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/> <%-- success --%>
</c:if>
{code}
{code} router.jsp ( maps the jsp page based on success and failure)
<?xml version="1.0" encoding ="iso-8859-1"?>
<%-- /WEB-INF/jsp/cwjsps/router.jsp --%>
<%@ taglib prefix="c" uri=" %>
<%@ taglib prefix="fmt" uri=" %>
<%@ taglib prefix="sql" uri=" %>
<%@ taglib prefix="x" uri=" %>
<%@ taglib prefix="fn" uri=" %>
<%-- setup session if one does not exist --%>
<%@ page session="true" %>
<%-- set up debug variable --%>
<c:set var="sessDebug" scope="session" value="true"/>
<%-- get pathinfo information from the request --%>
<%-- this defines which use case has been requested --%>
<c:set var="pgePathInfo" scope="page" value="${pageContext.request.pathInfo}" />
<%-- uc02 : Login --%>
<c:if test="${pageScope.pgePathInfo =='/home'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>
</c:if>
<c:if test="${pageScope.pgePathInfo =='/login'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/prologin.jsp"/>
</c:if>
<%-- uc01 : View Details Of Books For Sale --%>
<c:if test="${pageScope.pgePathInfo =='/viewbooksforsale'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/probooksforsale.jsp"/>
</c:if>
<%-- uc01 : process User registration--%>
<c:if test="${pageScope.pgePathInfo =='/userregistration'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/proregistration.jsp"/>
</c:if>
<%-- uc01 : debug --%>
<c:if test="${pageScope.pgePathInfo =='/debug'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/debug.jsp"/>
</c:if>
<%-- uc01 : view Traders Own View --%>
<c:if test="${pageScope.pgePathInfo =='/Traderhomepage'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/Traderhomepage.jsp"/>
</c:if>
<%-- otherwise --%>
<jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>