java - unable to display jsp data in table -


i've below jsp

<table>         <thead>             <th>patient id</th>             <th>name</th>             <th>address</th>             <th>contact no</th>             <th>disease</th>             <th>doctor assigned</th>             <th>date</th>             <th>room assigned</th>         </thead>          <%             string query = "select id, name, address, contactnumber,disease,docassign,joining, roomassign patient";             preparedstatement ps = conn.preparestatement(query);             resultset rs = ps.executequery();             while (rs.next()) {         %>         <tr>             <td>                 <%                     out.print(rs.getint(1));                 %>             </td>             <td>hi</td>         </tr>         <%             }         %>     </table> 

i'm running query , data table td. query running fine problem if take <td><%out.print(rs.getint(1));%></td>, value displayed in td, when i'm trying using <td><%rs.getint(1);%></td>, td showing blank.

i want know if in jsp, display value, have use out.print() sure, or can display value directly using <td><%rs.getint(1);%></td>.

there 2 basic ways display values in jsp. first, noted, can execute code between <% , %>. if use out.print or out.println there, displayed on page:

<% out.print(rs.getint(1)); %> 

alternatively, can have expression between <%= , %> (note =!). expression printed page:

<%= rs.getint(1) %> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -