• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to display records in html using servlets

 
Vaishali Paramane
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
 
sudhir nim
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
 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please return the complete HTML content along with the records, from the Servlet.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
Java MS IE
  • 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.
 
Gaurav Sagar
Ranch Hand
Posts: 97
Java MySQL Database
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • 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
Rancher
Posts: 1625
5
Android Java Java ME
  • 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
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic