I am in need of your help. I have a piece of code which reads data from a database and writes it to a flat file. Instead of writing it to a flat file we have to present it in a structured way using HTML.Here I don't know taht I have to create (embed) the whole HTML tags in the program itself or how to generate a HTML file using core Java.This is just to display the output(something like reports in HTML).Please help me folks.This is very urgent. TIA, Regards, Murali
"Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution, and the vision to see obstacles as opportunities"
I'd investigate JSP, PHP or other server-side template technology to accomplish this, but, that said, if you insist on generating markup in Java check out the Jakarta ECS project. With ECS you build up an object DOM in memory, then serialize it to HTML, XHTML or a handful of other markups. Much preferred to building up markup in a string buffer. hth, bear [ November 07, 2002: Message edited by: Bear Bibeault ]
here is a sample of oututting html from a servlet. as you can see it is not fun. especially when you have quotes inside qoutes inside quotes. that is part of the reason they came up with JSP.
out.println("You have 10000 </font><font color='yellow'>Gold Pieces </font><font color='white'>" + name + "<p>Would you like to take a quiz?<br>I will give you 10000 <font color='yellow'>Gold Pieces </font>" + "<font color='white'>for each correct answer.<p><form>" + "<input type='button' value='Sure, why not!' on_Click=\"top.frames[1].location='http://www.javaguy.dns2go.com/examples/Quiz.html'\">" + "<p><input type='button' value='No, I have enough gold.' on_Click=\"parent.location.replace('http://www.javaguy.dns2go.com/examples/MagicItems.html')\"></form>" + "</b></body></html>"); out.close(); } }
Hi Folks, Tx for your qucik reply. I'll explain my problem in another context. I want to design a HTML page first. In that I have to map the data which I got from database and then write it to another file and save it as .HTM or .HTML. How will I do that?. Should I have to set some rules like between any delimeters ie #FNAME#,I have to replace it with actual value from the database. ie #FNAME# --> Murali Is there any facility (class or package)available for this?.Please let me know if any. Other ideas are welcome. Thanks, Murali
"Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution, and the vision to see obstacles as opportunities"