User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JSP section within the Web Development category of DaniWeb, a massive community of 402,750 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,457 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JSP advertiser: Lunarpages JSP Web Hosting
Views: 29082 | Replies: 2 | Solved
Reply
Join Date: Aug 2005
Posts: 1
Reputation: hellofriend is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
hellofriend hellofriend is offline Offline
Newbie Poster

Solution JSTL compare string

  #1  
Aug 26th, 2005
hi, :p

i am trying to achieve a registration page in JSP. i am using tag library to do this.

c tag library and Sql tag library.





<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<c:if test="${param.submitted}">
	<c:if test="${empty param.name}" var="noname" />
	<c:if test="${empty param.pw}" var="nopw" />
	<c:if test="${empty param.cpw}" var="nocpw" />
<c:if
test="${not (noname or nopw or nocpw or requestScope.takenName)}">


<c:set value="${param.name}" var="name" scope="request" />
<c:set value="${param.pw}" var="pw" scope="request" />
<c:set value="${param.cpw}" var="cpw" scope="request" />




<jsp:forward page="postregister.jsp"/>



	</c:if>
		</c:if>

<html>
<head> 
</head>
<body bgcolor="CFECEC" >



<form method="post" name="frmRegister">
<input type="hidden" name="submitted" value="true"/>






<script type="text/javascript">

<!--

	function add_onclick() {
		
		var TRUE = new Boolean("True")
		var FALSE = new Boolean("False")
		
		blnError = FALSE
		strError = "The following problems were found in your registration form: \n\n"
		
		
			
		if (frmRegister.name.value == "")
			{
				blnError = TRUE
				strError = strError + " - You must provide a Login Name\n"
			};
			
		if (frmRegister.pw.value == "")
			{
				blnError = TRUE
				strError = strError + " - You must provide a Password\n"
			};
		if (frmRegister.cpw.value == "")
			{
				blnError = TRUE
				strError = strError + " - You must confirm your Password\n"
			};
			
			
		if (frmRegister.pw.value != frmRegister.cpw.value)
			{
				blnError = TRUE
				strError = strError + " - Your Password does not match\n"
			};
			
		if (blnError == TRUE)
			{
				strError = strError + "\nPlease correct these mistakes and try again."
				alert(strError)				
			}
		else
			{
				frmRegister.submit()
			};				
		
	}

	//-->
	</SCRIPT>




<p align="left"><b> Register <hr> </p>
<p align="center"><b>Please complete the following registration form</b>  <hr><br><br>



<img src="dmu.jpg" alt="DMU University" align="left">
<img src="dmu.jpg" alt="DMU University" align="right">



<table BORDER="0" ALIGN="CENTER" VALIGN="TOP" CELLPADDING=2 CELLSPACING=0>
<tr> 
<td><Strong>Username</strong></td>
<td><input type="text" name="name" value="<c:out value="${param.name}" />"
/>

</td>
</tr>


<tr> 
<td><Strong>Password</strong></td>
<td> <input type="password" name="pw"  value="<c:out value="${param.pw}"/>"
/>




<tr> 
<td><Strong>Confirm password</strong></td>
<td> <input type="password" name="cpw"  value="<c:out value="${param.cpw}"/>"
/>

<tr><td>&nbsp;</td>
<td><input type="submit" value="register"LANGUAGE=javascript onclick="return add_onclick()" />
</td>
</tr>





</table>
<img src="dmu.jpg" alt="DMU University" align="left">
<img src="dmu.jpg" alt="DMU University" align="right">



</form>
</body>
</html>


code describe dabove is register.jsp which send info to postregister.jsp. which described below
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>




<c:choose>

<c:when test ="${param.pw == param.cpw}">






<sql:setDataSource
	dataSource= "jdbc/ma123"
	scope="session"/>




<sql:transaction isolation="serializable">
	<sql:query var="result" >
    		select username from rptable where username=?
               <sql:param value="${requestScope.name}" />



		
	</sql:query>



	<sql:update>
		insert into rptable(username,password) VALUES (?,?);
		<sql:param value="${requestScope.name}" />
			<sql:param value="${requestScope.pw}" />
				
	</sql:update>

</sql:transaction>

</c:when>
<c:otherwise>
<c:redirect url="register.jsp" >
</c:redirect>
</c:otherwise>
</c:choose>
<%----
<c:set var="user" scope="session" value="${requestScope.name}" />
---%>
<jsp:forward page="login.jsp"/>





<%----

it trasfering same data 2 times in database.

---%>


it is transfering same data 2 times. so i do not understand what to do to compare password and confirm password.

any help would be greateful!!!!!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2008
Posts: 1
Reputation: fbeli is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
fbeli fbeli is offline Offline
Newbie Poster

Re: JSTL compare string

  #2  
10 Days Ago
try put after onClick parans in input submit the value return false; <input onClick="test(); return false"/>
Reply With Quote  
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,239
Reputation: peter_budo is a jewel in the rough peter_budo is a jewel in the rough peter_budo is a jewel in the rough 
Rep Power: 10
Solved Threads: 270
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: JSTL compare string

  #3  
10 Days Ago
Awn, I think he may already sorted or give up on this problem. Post is 3 year OLD!!!!!!!!
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JSP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JSP Forum

All times are GMT -4. The time now is 8:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC