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]

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.
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