• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to display Database query in JSP?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys I'm pretty much lost as to what to do.

I have configured my DB and am using hibernate, I wrote a successful query




I have also configured a browser file with the hibernate query.




Now what I want to do is display the whole table in JSP when a user selects 10 as the course credit hours

I have no idea how to do that, all I have is this.



How would I write this , any suggestions??
 
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Iterate over the course list and print out properties for each item:



But writing such code in a JSP is not recommended. You should use the tag <iterate> in the JSTL.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Get the information in the servlet page controller for the JSP and then use there JSTL and EL to create the HTML for display.

Putting Java code in a JSP is a poor practice that has been discredited for almost 10 years.
 
Jane Skylar
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Get the information in the servlet page controller for the JSP and then use there JSTL and EL to create the HTML for display.

Putting Java code in a JSP is a poor practice that has been discredited for almost 10 years.



I did as you have suggested and added spring framework MVC. I am using a controller class now.

I can display the data just fine but so far I only know one operation a query.





How do I expand this so I can insert and delete records into the database?

and How do I say pass variables into this controller from a JSP page lets say a user clicks a button (delete)

and it passes the action of deleting a specific entry to the controller preforms the delete and updates the database?
 
Haina Minawa
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jane Skylar wrote:
I did as you have suggested and added spring framework MVC. I am using a controller class now.



Seems you are going on the right track.


Jane Skylar wrote:
How do I expand this so I can insert and delete records into the database?


Which context does the question imply? Hibernate or Spring MVC?


Jane Skylar wrote:
and How do I say pass variables into this controller from a JSP page lets say a user clicks a button (delete)



Use Spring's form tag in the JSP page and use the @ModelAttribute in the Spring action's method with a proper form bean object.


Jane Skylar wrote:
and it passes the action of deleting a specific entry to the controller preforms the delete and updates the database?




Just creating other action methods that do the jobs of delete and update.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic