Forums Register Login

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

+Pie Number of slices to send: Send
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)

+Pie Number of slices to send: Send
In PromotionDB, does the loop add any elements to the ArrayList? Add some logging to find out for sure.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Debugging or logging saves ton of time as this situation.
On top of spaghetti all covered in cheese, there was this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 8296 times.
Similar Threads
Retriving time from Oracle database in JSP
Need help in JSP/Servlets
How to retrive the data using foreach tag or sql data tag by using jstl
how to getSession in simple java class?
page gets hang on runtime
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:42:47.