• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

how to display records in html using servlets

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 312
MS IE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please return the complete HTML content along with the records, from the Servlet.
 
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
MS IE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The author wanted to use HTML and Servlets only, hence, I had given that solution.
 
Ranch Hand
Posts: 97
MySQL Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 2266
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly do you mean by

Can I call jsp in html?

 
Swastik Dey
Bartender
Posts: 2266
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps this article might help.

And if you are new to JSP, read this article as well.
 
Vaishali Paramane
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for help

Now I will read JSP to find out solution
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic