0

Hi All,

Is there a way to create a HTML file generated in browser in a JSP file?
This same JSP file parsed by server and show up in a browser in HTML form
and also save this HTML form to a HTML file on the server.

The only way I can think of is using a StringBuffer to append all the HTML form data
and save to a file at the end of the JSP file?

Something like

<%
StringBuffer htmlBuffer = new StringBuffer();
htmlBuffer.append("<HTML><HEAD>");
....
%>
......
<table width=100%>
  <tr>
  <td>Test This Data</td>
  </tr>
</table>
<%
   htmlBuffer.append<"\n<table width=100%>")
   .append("\n<tr>")
   .append("\n<td>Test This Data</td>")
   .append("\n<\tr>")
   .append("\n</table>");
%>

And eventually save this StringBuffer to a file.

I was wondering if there is any easier way.
I'd really appreciate it if anyone can shed some light.

thanks in advance.

-Tian

Edited by peter_budo: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks)

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by javaAddict
0

JSPs are meant for creating static HTML pages with dynamic content. So you don't need StringBuffer.append(?).. All you need is calling JSP tags and scriptlets and saving the file with .jsp extn.

0

You can directly write html code in a jsp file.JSP out object is use for that purpose .

out.println("<html>");
 out.println("<body><p>");
 out.println("</p></body>");
 out.println("</html>");
0

Even if you do write code that create a file with the .jsp extension and save it at the server, what would be its use. You would still need to call it and display it to browser.
Even if you create a dynamic link based on the name of the .jsp file that you programaticaly created there is no practical use for such technique.

What are you trying to accomplish?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.