Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-27-2008, 02:35 AM
Member
 
Join Date: Mar 2008
Posts: 2
koushika is on a distinguished road
unable to update MYSQL with values from jsp page
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing boolean Values of another values in one class. a_iyer20 Advanced Java 4 04-15-2008 02:04 PM
have to make the bookisbn column values as hyperlink to a page name bookinfo.jsp whi koushika New To Java 0 04-01-2008 05:14 PM
passing values from main page to pop up window vicky JavaServer Pages (JSP) and JSTL 2 01-18-2008 12:24 PM
Unable to compile gapper New To Java 2 01-14-2008 05:31 PM
Problem inserting values to MySQL tables from the Data Source Explorer tip Eclipse 0 12-24-2007 10:47 AM


All times are GMT +3. The time now is 10:46 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org