This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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: 20177
25
MySQL Database
  • 0
  • 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.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic