Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to show a table in Servlet

 
Nick Lee
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I got a little question about how to show the html like pages in the servlet.I can only use
ServletOutputStream out = res.getOutputStream();
to print sth on the brower,but it's can only show the string on the brower,not the table or even buttons.
Can we do this without JSP files?
 
Juanjo Bazan
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use a PrintWriter to send Strings to the browser, but if that Strings are html text, you can send tables, buttons or whatever html element.
Here is a sample:

Of course you can also use the Dispatcher to forward the request/response to a jsp and delegate the view to a "view component".
Search for Model 2.
HTH
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13055
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could also use one of the template based schemes where the servlet reads in a HTML formatted file that has special markers to show where the servlet is supposed to insert data.
Bill
 
Nick Lee
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know,thank u very much.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic