Select results from Database

Posted on 2004-11-15
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 ( {
         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

     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 ( {
                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

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


    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    password protect pdf 11 69
    How to group array of objects ? 5 58
    Java Script nested call 3 38
    instanceof  operator in java 26 57
    It Is not possible to enable LLDP in vSwitch(at least is not supported by VMware), so in this article we will enable this, and also go trough how to enabled CDP and how to get this information in vSwitches and also in vDS.
    OfficeMate Freezes on login or does not load after login credentials are input.
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now