Easy way to generate html out put using servlet

Hi Techies,

Is there any easy way to generate html output using servlets. my project consist of more than hundred servlets which will output html content after server side processing. I feel more time is wasted in writing code for generating the html content.is there any tool which converts html source file to equivalent java source code..

Thanks..

[377 byte] By [ggayu] at [2007-9-26 2:26:29]
# 1
Java Server Pages?
peeveen at 2007-6-29 9:39:23 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 2
Thanks a lot. but what if we wouldlike to stick on to servlets.. rather than JSP ?. Is there any other way ?
ggayu at 2007-6-29 9:39:23 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 3

If you have static HTML code, it wouldn't be difficult to write a program that read in that code, chopped it into bits, and wrote out a servlet that served out that page with a sequence of out.print(...) statements. But you wouldn't want to do that, because why not just have the web server serve out the page directly?

If you find yourself writing the same code repeatedly, then you are in a standard refactoring situation. You have standard page headers, for example? Have your servlet descend from a standard servlet that contains a writeHeader() method, and so on.

DrClap at 2007-6-29 9:39:23 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...
# 4

You might want to take a look at XSL. Using XSLT you can limit your Servlet output to an XML representation of the data you want to show on the HTML pages. You can then let somebody else (with XSL and HTML experience) create the XSL templates which create the HTML.

If you want you can do the XSL transformation on the server side, but client-side transformation can in some circumstances be a very powerfull method.

Look at www.w3.org/Style/XSL and the Xalan project on www.apache.org.

Hope this helps,

Silvio Bierman

silviobierman at 2007-6-29 9:39:23 > top of Java-index,Archived Forums,Java 2 Software Development Kit (J2SE SDK)...