aspose file tools*
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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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();
}
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: creating html file from jsp
 
Similar Threads
jBoss and EL
Form in New window
Selectbox in Javascript
JSP Include
checkbox in jsp! urgent!!!!!!!!