display the result in the form of table in JSP

Hello,

I am using Beans and JSP and vector to pull the data from the database and showing it in the JSP.

I want to display the result in the JSP like this
The result for Logical Name **** is:  **********row1
 (cell1)Vendor: (cell2)ATT Paradyne *********row2
(cell1)Model: (cell2)Comshpere 3610 *********row3
.....and so on

but I am getting the result like this

The result for Logical Name *** is:  (row1)
 Vendor: ATT Paradyne Model: Comshpere 3610 SerialNumber: 4041095 OpSys: All Function: null Group: Network Facility: A1 Grid-AAA: null Grid-999: null Cabinet: Bay-8 Row: NSC  (row2 and all in one cell)

This is the code I have used:
**********************JSP*************************
......
<%
     Simple_SearchBean.processRequest(request,session);
          Vector Ssresult_vec = new Vector ((Vector) Simple_SearchBean.getSsresult_vec());
                        ListIterator iter_res = Ssresult_vec.listIterator();
%>
<table border ="1">
       <tr>
       <th>The result for Logical Name <%=request.getParameter("Logicalnm_lst")%>  is:  </th>
                </tr>
       <tr>
                            <% while (iter_res.hasNext()) {
                      String value = (String)iter_res.next();
                %>
            <td>  <%=value%> </td>
        </tr>
       <% } %>      
 </table>

*******************Bean********************
try {
        st=conn.createStatement();                       
       rs=st.executeQuery("Select Vendor,Model,[Serial Number],OpSys,Function,Group,Facility,[Grid-Aaa],[Grid-999],Cabinet,Row from [Base Inventory Table] where [Logical Name] = '"+request.getParameter("Logicalnm_lst")+"'");
      Ssresult_vec.clear();
              while(rs.next()) {
        c1 = "Vendor: "+ rs.getString("Vendor");
        c2 = "Model: " + rs.getString("Model");
        c3 = "SerialNumber: " + rs.getString("Serial Number");
            .....
                   Ssresult_vec.addElement( c1+ "\n" +c2+ "\n" + c3+ "\n" + c4+ "\n" +c5+ "\n" +c6+ "\n" +c7+ "\n" +c8+ "\n" +c9+ "\n" +c10+ "\n" +c11+ "\n" );
}
}catch(SQLException exe){}

Do I have to add a for loop for the table too in the jsp?

Please help,
Thanks


nubeeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

kiranhkCommented:
change this to

     <tr>
                          <% while (iter_res.hasNext()) {
                    String value = (String)iter_res.next();
              %>
          <td>  <%=value%> </td>
       </tr>


**************************

 
                          <% while (iter_res.hasNext()) {
    <tr>
                    String value = (String)iter_res.next();
              %>
          <td>  <%=value%> </td>
       </tr>

     <% } %>  
0
nubeeAuthor Commented:
Thanks Kiranhk for your quick response,

I tried it like you said:

<% while (iter_res.hasNext()) {%>
              <tr>
             <% String value = (String)iter_res.next();%>
             
             
      <td> <%=value%> </td>
        <tr/>

Its still the same :(
0
nubeeAuthor Commented:

Do you think its because of the Bean code?
here I am already attaching the string Vendor, Model etc..

c1 = "Vendor: "+ rs.getString("Vendor");
       c2 = "Model: " + rs.getString("Model");
       c3 = "SerialNumber: " + rs.getString("Serial Number");
            .....
                 Ssresult_vec.addElement( c1+ "\n" +c2+ "\n" + c3+ "\n" + c4+ "\n" +c5+ "\n" +c6+ "\n" +c7+ "\n" +c8+ "\n" +c9+ "\n" +c10+ "\n" +c11+ "\n" );
}
0
kiranhkCommented:
yes...... sorry, didnt go thro' properly earlier

If you do like this

Ssresult_vec.addElement( c1+ "\n" +c2+ "\n" + c3+ "\n" + c4+ "\n" +c5+ "\n" +c6+ "\n" +c7+ "\n" +c8+ "\n" +c9+ "\n" +c10+ "\n" +c11+ "\n" );

then u need to use StringTokenizer then only you can print it line by line....

so do this instead

while(rs.next()) {
       c1 = "Vendor: "+ rs.getString("Vendor");
Ssresult_vec.addElement( c1);
       c2 = "Model: " + rs.getString("Model");
Ssresult_vec.addElement( c1);
       c3 = "SerialNumber: " + rs.getString("Serial Number");
Ssresult_vec.addElement( c1);
            .....
}

then have the html code i gave above
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nubeeAuthor Commented:
SUPER.It worked.

Thanks kiranhk
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.