File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes How to show a table in 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 show a table in Servlet" Watch "How to show a table in Servlet" New topic

How to show a table in Servlet

Nick Lee
Ranch Hand

Joined: Dec 17, 2002
Posts: 45
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?

Nick Lee
Juanjo Bazan
Ranch Hand

Joined: Feb 04, 2002
Posts: 231
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.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12761
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.
Nick Lee
Ranch Hand

Joined: Dec 17, 2002
Posts: 45
I know,thank u very much.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: How to show a table in Servlet
Similar Threads
I passed SCJD :)
How to open a local file in Java program
mini browswer
how can dispaly the pics that are not included in the program folder.