Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with jsp displaying values from database  RSS feed

 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using jsp and servlets to create a website that displays houses for sale. You can search for houses in a certain city and it will display information from the database. But when you click on the picture of the house, I want more information to be displayed about it. But only the table headers are displaying so its not displaying the values from the database.
I created an Arraylist to display the values from the database.

here is the Arraylist code with the sql statement that is called:


here is the servlet code:


and here is the jsp code:


like i said, the jsp page is only displaying the table headers, not the information from the database
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please follow conventions. Not doing so makes code surprisingly hard to read. Variables should begin with lowercase; so dataDrillDownlist, not DataDrillDownlist. It also helps to use more readable variable names, so why not properties or PropertyList rather than the more mysterious and generic DataDrillDownlist?

Nothing pops out at me at first inspection. Time to do some debugging. I'd start by adding logging to the servlet to verify that the list is being populated as expected.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the <jsp:useBean> declaration confusing -- shouldn't ${DataDrillDownlist} automatically find the request property of that name without any such declaration?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, the useBean declaration is superfluous and should be removed.

Again: useBean is not used with the JSTL. Don't use it. Ever. Never.
 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
removing the useBeans declaration doesn't fix the problem
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't say it would; I said it was superfluous.

Have you added logging code to the servlet to check that the list contains the expected data?
 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried adding these lines to the else statement in the servlet but it didn't display anything:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Outputting to the response isn't appropriate; it'll interfere with the normal output. Either log using System.out, or use a real logging package such a JULI or Log4J. This is an essential skill you must learn in order to deal with situations exactly like this.
 
Karen Wilson
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
using system.out doesn't display anything either
System.out.println(DataDrillDownlist);
System.out.println(PropertyDB.getDataDrillDown(id));
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you think those statements don't display anything, that means you're looking in the wrong place. You should be looking in the logs for your web application, wherever they might be.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is actually a good exercise as getting logging enabled and working for you is an important part of diagnosing any issues now and in the future.

Those system print statements will print something, so finding where they're getting written is important. The two most common places are logs/catalina.out in the Tomcat installation, or the console if Tomcat is writing to the DOS window in which you started Tomcat if using Windows.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!