We help IT Professionals succeed at work.

Prepared statement jsp

l_starter_l
l_starter_l asked
on
661 Views
Last Modified: 2013-11-23
I have 2 prepared statements..How do I choose which one I can execute.e.g if the user leaves a one text field empty I want to execute preparedstatement 1 and if the user fills it in I want to execute prepare statement 2.

Also how do I display values from a database in jsp

That code shows all the rows I only want to show the row that was updated
<% while(resultset.next()){ %>
	  <td><%= resultset.getString(1) %></td>
          <td> <%= resultset.getString(2) %></td>
          <td> <%= resultset.getString(3) %></td>
        </tr>
        <% } %>

Open in new window

Comment
Watch Question

CERTIFIED EXPERT

Commented:
use if statement !!
check whether text box have value or not ... or temp set some value check equal to ur giving value means than excute 1st statement !!  
CERTIFIED EXPERT

Commented:
put ur resultset value in Bean after that bean will  added to list and passes to JSP

Technology Lead
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
k instead of showing all the values in the table.. How do I only show the value that was updated
CERTIFIED EXPERT

Commented:
@l_starter_l: In my opinion, it is not possible to do it this way. Since the html rendered at the client's end doesn't have the jsp scriplets (since they are processed at the server's end), putting an if statement doesn't make a difference, since the 'if' decision is not processed on the client side.

You can achieve this by putting these scriplets in the next jsp page to which current jsp page will submit its request to.

Thanks
Pass some filter paramter to you query.
Example1 : to see detail of student with rollno=10
            PreparedStatement preparedStatement1  = con.prepareStatement("select * from student where rollno=?");
            preparedStatement1.setInt(1,10);
            ResultSet resultset = preparedStatement1.executeQuery();
 
Example2: to see detail of student with city=mumbai
            PreparedStatement preparedStatement2  = con.prepareStatement("select * from student where city=?");
            preparedStatement2.setString(1,"mumbai");
            ResultSet resultset = preparedStatement2.executeQuery();
 

 
Ravi KallaTechnology Lead

Commented:
@l_starter_l : Please raise the next question you asked in ID: 25827135 as a new question. I am suggesting this because, the answer to your actual question should be awarded points properly.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.