aspose file tools*
The moose likes Servlets and the fly likes how to display records in html using servlets 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 records in html using servlets" Watch "how to display records in html using servlets" New topic
Author

how to display records in html using servlets

Vaishali Paramane
Ranch Hand

Joined: Mar 05, 2007
Posts: 106
Hi
I want to design html page for student data.



student Id

Student Name

Student address




Add Edit Delete



Can anyone tell me how I can do it using html and servlet.

I designed html page and gave all these three buttons same names but different values. I can fetch a record but i don't know how to pass these values from servlet to html.
How to return to same html page and display records.


Thanks

Vaishali


SCJP, SCJD
Preparing for SCWCD
sudhir nim
Ranch Hand

Joined: Aug 29, 2007
Posts: 212

Once you have data available in servlet, you can set it as request attributes, and then forward request to JSP, in JSP you can access these data from request attributes using JSP EL and jstl, and generate html markup


[Servlet tutorial] [Servlet 3.0 Cook Book]
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

Please return the complete HTML content along with the records, from the Servlet.


S.D. MADHAN
Not many get the right opportunity !
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Madhan Sundararajan Devaki wrote:Please return the complete HTML content along with the records, from the Servlet.

Not a good idea. sudhir's approach of using a JSP to generate the HTML is the correct approach.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Madhan Sundararajan Devaki
Ranch Hand

Joined: Mar 18, 2011
Posts: 312

The author wanted to use HTML and Servlets only, hence, I had given that solution.
Gaurav Sagar
Ranch Hand

Joined: Sep 08, 2010
Posts: 97

You can use a table to display these values in a tabular fashion, but using JSP instead of servlet for HTML would be the best way.

Regards,
Gaurav Sagar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Madhan Sundararajan Devaki wrote:The author wanted to use HTML and Servlets only, hence, I had given that solution.

Guiding people away from poor solutions is one of the Ranch's duties. Remember that CodeRanch is a learning site, not a "get quick answers" site.
Vaishali Paramane
Ranch Hand

Joined: Mar 05, 2007
Posts: 106
Thanks for reply

Can I use javascript to pass values and get values from servlet.

If yes can anyone give me some example or site name where I can learn.

If no please suggest me other solution.

Can I call jsp in html?

Thanks

Vaishali
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

What exactly do you mean by
Can I call jsp in html?


Swastik
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Typically this should be your flow

Htm/jsp page sends request to servlet. Servlet with the help of helper classes performs the business and data access logics and creates a response. This response is forwarded to a jsp page to produce the output.

Correct me if I am wrong.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Perhaps this article might help.

And if you are new to JSP, read this article as well.
Vaishali Paramane
Ranch Hand

Joined: Mar 05, 2007
Posts: 106
Thanks for help

Now I will read JSP to find out solution
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to display records in html using servlets