Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<sql:query datasource="${dbsource}" var="result2" xmlns:sql="#unknown">
            SELECT * from Users;
           </sql:query>
           
            <c:out value="${param.name}" xmlns:c="#unknown" />
            <br>
         
         
         <c:foreach var="row" items="${result2.rows}" xmlns:c="#unknown">
         <c:out value="${param.user_name}" /><br>
         
         <c:choose>
         
            <c:when test="${param.name eq row.user_name}"> 
	        <font size="5" color="red">UserName Already Exists .Please choose different name</font><br>
	        <a href="NewUser.jsp">Enter Other UserName</a> 
	        </br></c:when> 
          
        
         <c:when test="${param.name ne param.user_name}"> 
         <sql:update datasource="${dbsource}" var="result" xmlns:sql="#unknown">
            INSERT INTO Users(user_name,user_role,user_skill,rating) VALUES (?,?,?,?);
            <sql:param value="${param.name}" />
            <sql:param value="${param.role}" />
            <sql:param value="${param.skill}" />
            <sql:param value="${param.rating}" />
          </sql:update>
      
        
          <c:if test="${result&gt;=1}">
          <font size="5" color="green"> Congratulations ! Data inserted
          successfully.</font>
            
            
           <c:redirect url="NewUser.jsp">
           <c:param name="susMsg" value="Congratulations ! Data inserted successfully." />  
           </c:redirect>   
           </c:if> 
            
           </c:when> 
           
           <c:otherwise></c:otherwise>
           
        </c:choose>    
         </br></c:foreach>


[edit]HTML encode, code blocks.[/edit]

What I have tried:

I created a table.I wanted to add new User Details.If that user is already there in the database it should ask user name already Exists.other wise should get one page
with all textfileds.and I have to add all the values successfully to the database.

I tried with below tags alsoo..

XML
<c:if test="${param.name eq row.user_name}" xmlns:c="#unknown"> 
<c:if test="${param.name ne row.user_name}"></c:if></c:if></br>
Posted
Updated 12-Sep-16 1:34am
v2

1 solution

Sorry I went to put a comment but due to formatting I couldn't write what I wanted which is ironic


is this a format bug or the real code
<c:if test="${result&gt;=1}">

wouldn't the correct format be

<c:if test="${result >=1}">


/Darren
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900