This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JSP and the fly likes creating html file from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "creating html file from jsp " Watch "creating html file from jsp " New topic
Author

creating html file from jsp

Ikasari Widiyanto
Greenhorn

Joined: May 31, 2004
Posts: 29
Hi,

I would like to know how to create html file from jsp. Can anyone provide me with the sample code or the links of to do that? thanks.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

By "HTML file" do you mean create a new file or generate HTML? JSP's generate HTML anyway - when you access a URL which is a JSP, code runs on the server to generate the correct markup tailored for the request if necessary. If you want to create a new HTML file, you can do this as you would from a normal Java class with the IO packages in the API.
[ December 07, 2004: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ikasari Widiyanto
Greenhorn

Joined: May 31, 2004
Posts: 29
yah, I want to create html file from jsp same like create new text file. Is it something like this?

String path="../../../root/card/lala.html";
try
{
File f = new File(path);
PrintWriter out1 = new PrintWriter(new FileWriter(f));
out1.write("<html>");
out1.write("<head>");
out1.write("<title>Create Christmas e-card</title>");
out1.write("<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">");
out1.write("</head>");
out1.write("<body bgcolor="#F0F0F0">");
out1.write("<table width="751" border="0">");
out1.write("<tr>");
out1.write("<td>To:</td>");
out1.write("<td></td>");
out1.write("<td>From:</td>");
out1.write("<td></td>");
out1.write("</tr>");
out1.write("<tr>");
out1.write("<td>Message:</td>");
out1.write("<td colspan="3"></td>");
out1.write("</tr>");
out1.write("</table>");
out1.write("</body>");
out1.write("</html>");
out1.close();
}catch(IOException e)
{
e.printStackTrace();
}
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: creating html file from jsp