Select results from Database

Posted on 2004-11-15
Medium Priority
Last Modified: 2010-04-01
Hopefully this is a simple question.  I’m working on a JSP page that will search a database and return the results based on the search.  After the results have been returned, I need to allow the user to select one of the results and then be directed to the appropriate page based on that selection.  I’ve been able to retrieve the resultSet and create a radio button beside each one, however I’m not sure how to pass the information of the result to the next page.  Please see the example code I’ve provided.  What do I need to change here?  Thanks

while (rs.next()) {
         String project = rs.getString(1);
         String testname = rs.getString(2);
         String testid = rs.getString(3);
         String description = rs.getString(4);

       <table border ="0" cellspacing="1" cellpadding = "1">
<input type = "radio"
name = "result"
value = testname
onClick="submit()" ><h1>Project Name: <%=project%>     , TestName:         <%=testname%> , Description: <%=description%></h1> <BR></input>
Question by:jhughes4

Accepted Solution

aleksmeza earned 500 total points
ID: 12586959
 You can use a form instead of onClick submittion, and you add a boton for submit, and also in the same cicle of the result set you can create this form, here's my code suggestion:

   <!-- in this form I'm assuming that you have a javascript function name submit() -->
  <form name="yourForm" method="POST" action="javascript:submit()">
     <table border ="0" cellspacing="1" cellpadding = "1">
     <% while (rs.next()) {
            String project = rs.getString(1);
            String testname = rs.getString(2);
            String testid = rs.getString(3);
            String description = rs.getString(4);
        <input type = "radio" name = "result" value = testname>
           <h1>Project Name: <%=project%>     , TestName:         <%=testname%> , Description:
           <%=description%></h1> <BR></input>
     <% } // while %>
        <input type="submit" name="Go" value="go" >             

   I think this is a clearly way to do this, hope this help :)

   Alex Meza

Author Comment

ID: 12587597
On the next jsp page when I do request.getParameter( "result" )) it just returns testname as opposed to the value of testname.


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If anyone asked you to network diagram of the internet, it was drawn in the form of a fluffy cloud which further became known as cloud computing. Popularly cloud computing is defined as workloads that run over the internet in a commercial provider’s…
Social messanging services like WhatsApp and Facebook can help businesses in ways that many owners don't even imagine, giving new opportunities to connect with customers. Discover some of the most innovative things they can do for your company.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question