Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Data Not displayed in JSP Page , just want to display data in a jsp from Database

 
Vishal Hegde
Ranch Hand
Posts: 1077
Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64701
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The time to be putting Java code into a JSP is long, long passed. 10 years in fact. 10 years! It's high time to come up to speed with the JSTL and EL and to stop writing JSP pages like it is still 2001.

Move all the Java code to a servlet and other Java classes where it belongs. Capture the DB data in Java constructs that you place into request scope, and use the JSTL and EL on the JSP page to display the data.

Read this article.
 
Paul Clapham
Sheriff
Pie
Posts: 20958
31
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your post demonstrates one of the problems inherent in scriptlets: you have some Java code and you have some HTML code, and it's mashed together in one place. The Java code should be indented one way, and the HTML should be indented another way. However not only have you not attempted to do that, you haven't got any meaningful indentation at all, so it's very hard to see if your Java braces match or your HTML tags match. (Hint: they don't.)

And your code at lines 36 to 38:

indicate that you haven't quite understood how JSPs work. They can be replaced by this simpler code:

because all of your JSP code except the scriptlets is automatically written to the response.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic