aspose file tools*
The moose likes Servlets and the fly likes How to display values from database to html page using servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display values from database to html page using servlet" Watch "How to display values from database to html page using servlet" New topic
Author

How to display values from database to html page using servlet

pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 63
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: 3479

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: 12
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 ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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 ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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: 3479

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to display values from database to html page using servlet