| Author |
How to display values from database to html page using servlet
|
pravin rasal
Ranch Hand
Joined: Jul 27, 2011
Posts: 50
|
|
|
I want to display values form database to html page using servlet how can do this...
|
 |
Nitin Surana
Ranch Hand
Joined: Jan 21, 2011
Posts: 129
|
|
Expression tags are used to display information on JSP.
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3334
|
|
|
What is your question exactly? How to get the data from a database or how to display the retrieved data?
|
 |
yogesh m gaikwad
Greenhorn
Joined: Dec 28, 2011
Posts: 4
|
|
write in servlet...
String details="";
details = "<html> <body>";
details = details + "<table border=1><tr><td><Strong>Roll No <td>:</td> </Strong></td><td>" + sr.getRollno() + "</td></tr><br></br><tr><td><Strong>Name <td>:</td> </Strong></td><td>" + sr.getName() + "</td></tr><br></br><tr><td><Strong>Password <td>:</td> </Strong></td><td>" + sr.getPassword() + "</td></tr><br></br><tr><td><Strong>Mobile No <td>:</td> </Strong></td><td>" + sr.getContact1() + "</td></tr></table>";
details += "</body></html>";
first get the values from database and then put it instead of sr.getRollno() and so on..........
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
Nitin Surana wrote:Expression tags are used to display information on JSP.
No they are not. At last not in 2012. That notation was discredited 10 years ago. 10 years!
Time to update your JSP knowledge with the JSTL and EL. 10 years is long enough, don't you think?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
yogesh g gaikwad wrote:write in servlet...
Again, no.
Creating HTML in a servlet is a horrible practice.
Gather the data from the DB, store it in Java collections, add the collections to the request as scoped variables, and forward to a JSP to create the view.
|
 |
Nitin Surana
Ranch Hand
Joined: Jan 21, 2011
Posts: 129
|
|
Bear Bibeault wrote:
Time to update your JSP knowledge with the JSTL and EL. 10 years is long enough, don't you think?
I do agree with you.
I said expression tag taking him to be a beginner. You don't expect a beginner to directly start with JSTL and EL. Atleast I don't expect that.
|
 |
Bear Bibeault
Author and opinionated walrus
Marshal
Joined: Jan 10, 2002
Posts: 50691
|
|
Nitin Surana wrote:
Bear Bibeault wrote:
Time to update your JSP knowledge with the JSTL and EL. 10 years is long enough, don't you think?
I said expression tag taking him to be a beginner. You don't expect a beginner to directly start with JSTL and EL.
I absolutely do! Scriptlets are not for beginners -- they are old technology. Beginnners should learn the new technologies and develop good habits right away. Why should they learn something that they're not supposed to use? Why instill bad practices and bad habits at the outset?
Would you suggest that Java beginners learn Java 1.1 rather than Java 6 or 7?
Java code in a JSP is a bad practice for beginners and the experienced alike, and should never, ever, be used in any web page created after 2002.
|
 |
Hussein Baghdadi
clojure forum advocate
Bartender
Joined: Nov 08, 2003
Posts: 3334
|
|
Nitin Surana wrote:
Bear Bibeault wrote:
Time to update your JSP knowledge with the JSTL and EL. 10 years is long enough, don't you think?
I do agree with you.
I said expression tag taking him to be a beginner. You don't expect a beginner to directly start with JSTL and EL. Atleast I don't expect that.
My guitar teacher is so strict when it comes to develop the right technique from the very beginning, because it is hard to get ride off the bad habits.
JSTL and JSP EL aren't really challenging after all.
|
 |
 |
|
|
subject: How to display values from database to html page using servlet
|
|
|