JSTL compare string

Thread Solved
Reply

Join Date: Aug 2005
Posts: 1
Reputation: hellofriend is an unknown quantity at this point 
Solved Threads: 0
hellofriend hellofriend is offline Offline
Newbie Poster

JSTL compare string

 
0
  #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.

  1.  
  2.  
  3.  
  4.  
  5.  
  6. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
  7. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  8.  
  9. <c:if test="${param.submitted}">
  10. <c:if test="${empty param.name}" var="noname" />
  11. <c:if test="${empty param.pw}" var="nopw" />
  12. <c:if test="${empty param.cpw}" var="nocpw" />
  13. <c:if
  14. test="${not (noname or nopw or nocpw or requestScope.takenName)}">
  15.  
  16.  
  17. <c:set value="${param.name}" var="name" scope="request" />
  18. <c:set value="${param.pw}" var="pw" scope="request" />
  19. <c:set value="${param.cpw}" var="cpw" scope="request" />
  20.  
  21.  
  22.  
  23.  
  24. <jsp:forward page="postregister.jsp"/>
  25.  
  26.  
  27.  
  28. </c:if>
  29. </c:if>
  30.  
  31. <html>
  32. <head>
  33. </head>
  34. <body bgcolor="CFECEC" >
  35.  
  36.  
  37.  
  38. <form method="post" name="frmRegister">
  39. <input type="hidden" name="submitted" value="true"/>
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. <script type="text/javascript">
  47.  
  48. <!--
  49.  
  50. function add_onclick() {
  51.  
  52. var TRUE = new Boolean("True")
  53. var FALSE = new Boolean("False")
  54.  
  55. blnError = FALSE
  56. strError = "The following problems were found in your registration form: \n\n"
  57.  
  58.  
  59.  
  60. if (frmRegister.name.value == "")
  61. {
  62. blnError = TRUE
  63. strError = strError + " - You must provide a Login Name\n"
  64. };
  65.  
  66. if (frmRegister.pw.value == "")
  67. {
  68. blnError = TRUE
  69. strError = strError + " - You must provide a Password\n"
  70. };
  71. if (frmRegister.cpw.value == "")
  72. {
  73. blnError = TRUE
  74. strError = strError + " - You must confirm your Password\n"
  75. };
  76.  
  77.  
  78. if (frmRegister.pw.value != frmRegister.cpw.value)
  79. {
  80. blnError = TRUE
  81. strError = strError + " - Your Password does not match\n"
  82. };
  83.  
  84. if (blnError == TRUE)
  85. {
  86. strError = strError + "\nPlease correct these mistakes and try again."
  87. alert(strError)
  88. }
  89. else
  90. {
  91. frmRegister.submit()
  92. };
  93.  
  94. }
  95.  
  96. //-->
  97. </SCRIPT>
  98.  
  99.  
  100.  
  101.  
  102. <p align="left"><b> Register <hr> </p>
  103. <p align="center"><b>Please complete the following registration form</b> <hr><br><br>
  104.  
  105.  
  106.  
  107. <img src="dmu.jpg" alt="DMU University" align="left">
  108. <img src="dmu.jpg" alt="DMU University" align="right">
  109.  
  110.  
  111.  
  112. <table BORDER="0" ALIGN="CENTER" VALIGN="TOP" CELLPADDING=2 CELLSPACING=0>
  113. <tr>
  114. <td><Strong>Username</strong></td>
  115. <td><input type="text" name="name" value="<c:out value="${param.name}" />"
  116. />
  117.  
  118. </td>
  119. </tr>
  120.  
  121.  
  122. <tr>
  123. <td><Strong>Password</strong></td>
  124. <td> <input type="password" name="pw" value="<c:out value="${param.pw}"/>"
  125. />
  126.  
  127.  
  128.  
  129.  
  130. <tr>
  131. <td><Strong>Confirm password</strong></td>
  132. <td> <input type="password" name="cpw" value="<c:out value="${param.cpw}"/>"
  133. />
  134.  
  135. <tr><td>&nbsp;</td>
  136. <td><input type="submit" value="register"LANGUAGE=javascript onclick="return add_onclick()" />
  137. </td>
  138. </tr>
  139.  
  140.  
  141.  
  142.  
  143.  
  144. </table>
  145. <img src="dmu.jpg" alt="DMU University" align="left">
  146. <img src="dmu.jpg" alt="DMU University" align="right">
  147.  
  148.  
  149.  
  150. </form>
  151. </body>
  152. </html>

code describe dabove is register.jsp which send info to postregister.jsp. which described below
  1. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3.  
  4.  
  5.  
  6.  
  7. <c:choose>
  8.  
  9. <c:when test ="${param.pw == param.cpw}">
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. <sql:setDataSource
  17. dataSource= "jdbc/ma123"
  18. scope="session"/>
  19.  
  20.  
  21.  
  22.  
  23. <sql:transaction isolation="serializable">
  24. <sql:query var="result" >
  25. select username from rptable where username=?
  26. <sql:param value="${requestScope.name}" />
  27.  
  28.  
  29.  
  30.  
  31. </sql:query>
  32.  
  33.  
  34.  
  35. <sql:update>
  36. insert into rptable(username,password) VALUES (?,?);
  37. <sql:param value="${requestScope.name}" />
  38. <sql:param value="${requestScope.pw}" />
  39.  
  40. </sql:update>
  41.  
  42. </sql:transaction>
  43.  
  44. </c:when>
  45. <c:otherwise>
  46. <c:redirect url="register.jsp" >
  47. </c:redirect>
  48. </c:otherwise>
  49. </c:choose>
  50. <%----
  51. <c:set var="user" scope="session" value="${requestScope.name}" />
  52. ---%>
  53. <jsp:forward page="login.jsp"/>
  54.  
  55.  
  56.  
  57.  
  58.  
  59. <%----
  60.  
  61. it trasfering same data 2 times in database.
  62.  
  63. ---%>

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!!!!!!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1
Reputation: fbeli is an unknown quantity at this point 
Solved Threads: 1
fbeli fbeli is offline Offline
Newbie Poster

Re: JSTL compare string

 
0
  #2
Aug 27th, 2008
try put after onClick parans in input submit the value return false; <input onClick="test(); return false"/>
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,117
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 471
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is online now Online
Code tags enforcer

Re: JSTL compare string

 
0
  #3
Aug 27th, 2008
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)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 7
Reputation: haoyou2008 is an unknown quantity at this point 
Solved Threads: 1
haoyou2008 haoyou2008 is offline Offline
Newbie Poster

Re: JSTL compare string

 
0
  #4
Sep 9th, 2008
lol,so old post .........




<URL SNIPPED>
Last edited by peter_budo; Sep 9th, 2008 at 4:46 am. Reason: Keep It Spam-Free - Do not spam, advertise, plug your website, or engage in any other type of self promotion.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC