• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to display results in html dable

 
amila lakmal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear all

i'have jsp call view order.jsp when users click the view orders button in that jsp i want show all the details in the db in another jsp html table or i want display all the results in html table ... how can i do it

please help me .... its urgent
 
sheetanshu krishna
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Collect the requird data in rsultset & simply display that in jsp page using scriptlet

<table>

<%
while(rs.next())
{
%>
<tr>
<td><%=rs.getXXXX(1)%></td>
<td>............
</tr>
</table>

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sheetanshu krishna wrote:Collect the requird data in rsultset & simply display that in jsp page using scriptlet

Bad advice. Very bad.

As a new-comer to JSP it's important to learn good practices and habits right away. The use of Java code and scriptlets in JSP pages has been discredited for over 8 years now. Do not put Java code or scriptlets in JSP pages. Rather, use modern techniques such as the JSTL and EL.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65518
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a JSP newcomer, I suggest you read this article and this article.

Then you'll know that the data should be collected in the page controller for the JSP, and passed to the JSP as a scoped variable. There you will use JSTL and EL to construct the HTML table from the data.
 
amila lakmal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:As a JSP newcomer, I suggest you read this article and this article.

Then you'll know that the data should be collected in the page controller for the JSP, and passed to the JSP as a scoped variable. There you will use JSTL and EL to construct the HTML table from the data.



thank a you a lot Bear Bibeault for your helping hand for us
 
amila lakmal
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please im beg your pardon ....., im still in confuse please help me...
 
Paul Clapham
Sheriff
Posts: 21867
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're right, the advice in this thread was mostly of the form "Come on, it isn't 2003 any more". So to be more specific:

  • You should have a servlet which reads through the ResultSet and converts each of the rows to some custom Java Bean which you have designed for this purpose. It should put those beans into some kind of a List, an ArrayList would do just fine.
  • The servlet should put that list into the request context and then forward to the JSP.
  • The JSP should contain some JSTL code which processes the list and, for each element in the list, produces a <tr> element containing the data from the custom bean.


  • So that's broken down your problem into several smaller problems. Work on them one at a time.
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 65518
    105
    IntelliJ IDE Java jQuery Mac Mac OS X
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another hint: the <c:forEach> JSTL tag is what you would use to iterate over the List of beans.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!