userregistration.jsp ( view)

<c:url value="/cw/router/userregistration" var="UregPgeURL" scope="page"/>
<form action="${UregPgeURL}" method="get" >
<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}">
<c:out value="${requestScope.reqInvalidUserName}"/>
</c:if>

<tr>
<td width="157" align="right" >Department</td>
<td align="left" >
<select name="txtdepartment" id="txtdepartment" value="${param.txtdepartment}" >
<option></option>
<option>Faculty of Art and Design</option>
<option>Faculty of Business and Law</option>
<option>Faculty of Computing Sciences and Engineering</option>
<option>Faculty of Health and Life Sciences</option>
<option>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>
<c:if test="${!empty requestScope.reqInvalidDOB}">
<c:out value="${requestScope.reqInvalidDOB}"/>
</c:if>


<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}">
<c:out 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}">
<c:out 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}">
<c:out value="${requestScope.reqQueryErrorMessage}"/>
</c:if>
<c:if test="${!empty requestScope.reqInvalidUpdate}">
<c:out value="${requestScope.reqInvalidUpdate}"/>
</c:if>
proregistration.jsp(process page)
<?xml version="1.0" encoding ="UTF-8"?>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<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>

<-- validate txtdob --%>
<c:if test="${empty param.txtdob }">
<c:set var=reqInvalidDOB" scope="request" value= "Invalid Date Of Birth" />
</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>

<%-- check for query errors --%>
<c:catch var="insertQueryError">
<sql:update
var="pgeRowCount"
scope="page" >
<%-- insert details to trader table --%>
<c:catch var="pgeQueryError">
<sql:update var="pgeRowCount" scope="page">
INSERT into trader (dbTraderName,dbTraderDepartment,dbTraderProgramme ,dbTraderPhoneNum ,dbTraderDOB,dbTraderPNumber,dbTraderPwd)
VALUES (?,?,?,?,?,?,?,?)
<sql:param value="${param.txtname}"/>
<sql:param value="${param.txtdepartment}"/>
<sql:param value="${param.txtprogramme}"/>
<sql:param value="${param.txtphonenum}"/>
<sql:dateParam value="${txtdob}" type="date" />
<sql:param value="${param.txtuserid}"/>
<sql:param value="${param.txtpassword}"/>
</sql:update>
</c:catch>
<%-- check For query Error -- %>
<c: if test="${not empty pgeQueryError}">
<c:choose>
<%-- check For duplicate record --%>
<c:when test="${pgeQueryError.rootcause.errorCode == '1062'}">
<c:set var="reqQueryErrorMessage" scope="request" value="Duplicate Record" />
</c:when>

<c:otherwise>
<%-- database error --%>
<c:set var="reqQueryErrorMessage" scope="request" value="Database Error" />
</c:otherwise>
</c:choose>

<c:set var="reqOutcome" scope="request" value="failure" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/> <%-- failure --%>
</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:set var="reqOutcome" scope="request" value="success" />
<jsp:forward page="/WEB-INF/jsp/cwjsps/login.jsp"/> <%-- success --%>
</c:if>

Router.jsp (mapping URL)
<%-- setup session if one does not exist --%>
<%@ page session="true" %>
<%-- set up debug variable --%>
<c:set var="sessDebug" scope="session" value="false" />

<%-- 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/login.jsp"/>
</c:if>

<%-- uc01 : View Details Of Books For Sale --%>
<c:if test="${pageScope.pgePathInfo =='/viewbooksforsale'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/viewbooksforsale.jsp"/>
</c:if>

<%-- uc01 : User registration--%>
<c:if test="${pageScope.pgePathInfo =='/userregistration'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/userregistration.jsp"/>
</c:if>


<%-- uc01 : debug --%>
<c:if test="${pageScope.pgePathInfo =='/debug'}" >
<jsp:forward page="/WEB-INF/jsp/cwjsps/debug.jsp"/>
</c:if>

<%-- otherwise --%>
<jsp:forward page="/WEB-INF/jsp/cwjsps/home.jsp"/>

debug.jsp
<%-- \WEB-INF\jsp\cw\debug.jsp --%>
<%-- debug include file --%>

<c:if test ="${sessionScope.sessDebug == 'true'}">
<table border="1">
<c:forEach var="item" items="${cookie}">
<tr>
<td>inbound cookies</td>
<td>${item.key}</td>
<td>${item.value.value}</td> <%--note the .value.value--%>
</tr>
</c:forEach>

<c:forEach var="item" items="${param}">
<tr>
<td>inbound parameter</td>
<td>${item.key}</td>
<td>${item.value}</td> <%--note the .value--%>
</tr>
</c:forEach>

<c:forEach var="item" items="${requestScope}">
<tr>
<td>request scope object</td>
<td>${item.key}</td>
<td>${item.value.value}</td>
</tr>
</c:forEach>

<c:forEach var="item" items="${sessionScope}">
<tr>
<td>session scope object</td>
<td>${item.key}</td>
<td>${item.value.value}</td>
</tr>
</c:forEach>
</table>
</c:if>

1. cannot update mysql table with values from user registration form.
2. if i turn the sessionScope = "true" in router.jsp i get error while accessing userregistration.jsp