• 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

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In PromotionDB, does the loop add any elements to the ArrayList? Add some logging to find out for sure.
 
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
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: 285
2
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Debugging or logging saves ton of time as this situation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic