This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

why can't I display retrieved data from a mysql database on a webpage properly?  RSS feed

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How I want my code to work:
User types in a promo id, and data is retrieved from 'promotion' table in mysql according to what the user typed. For example, if user typed 'P01' for promo id, this is how it should look like (this is from a direct mysql query by the way):



The problem:
Data isn't displaying. (Only table headings are displayed)


There are no visible errors when I view my code in Eclipse.

moreinfo.jsp (takes in parameter of promo id; forwards it to PromotionDisplay servlet)



PromotionDisplayServlet



PromotionDisplay.java (object)



PromotionDB.java (takes in object PromotionDisplay)   



displayPromotion.jsp (display results in a tabular format)

 
Saloon Keeper
Posts: 4744
117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In PromotionDB, does the loop add any elements to the ArrayList? Add some logging to find out for sure.
 
Author and ninkuma
Marshal
Posts: 66801
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you should not be putting any Java code into the JSP. Move the DB fetch code into normal classes which you can test to be sure the data is being fetch correctly.

Then in a servlet, call the classes to fetch the data and send it to the JSP for display.

Please see this article for a discussion of why Java web apps should be constructed that way.
 
Ranch Hand
Posts: 197
1
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Debugging or logging saves ton of time as this situation.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!