Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP Design Question about paging data  RSS feed

 
Joe Brigs
Ranch Hand
Posts: 70
IBM DB2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'M new to JAVA & JAVAEE, if I should post this in a diffrent forum please let me know. I have a design Question ( part JSP). I want to read a Database and display the data in a JSP. The JSP has a previous and next Button that can page thru the resultset if theres mutiple rows. My 1st approach was to make the call to the DB in a Servlet using a while loop, but can you have the JSP return to the loop , when they click on a button ?
Is there a better approach ? I have looked thru some books and looked at many pages on the internet with no luck. I know this is pretty general question, sorry but Thanks for any help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, wrong approach. But not all that wrong (at least you aren't trying to access the DB in the JSP! )

There are a couple of resources you should read:
  • This entry in the JspFaq. It explains how to use the DB to do the heavy lifting.
  • This article that explains proper web app structure and why doing the DB access in a servlet (or worse, a JSP) is a poor practice.

  •  
    Joe Brigs
    Ranch Hand
    Posts: 70
    IBM DB2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    I'll be reading the links today. Thxs
     
    Joe Brigs
    Ranch Hand
    Posts: 70
    IBM DB2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks Bear , I used an approach in one of the DOCS and I'm now paging thru my data !
     
    Bear Bibeault
    Author and ninkuma
    Marshal
    Posts: 66141
    141
    IntelliJ IDE Java jQuery Mac Mac OS X
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!