• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where the html file is created??  RSS feed

 
Sandhya Deekonda
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
In my jsp file i need to create a html file.I'm doing that using FileOutStream,but i'm not knowing where the file is created.
here is the code

<%@page contentType="text/html"%>
<%@page import="java.io.*"%>
<jsp:useBean id="user" class="user.SaveComments" scope="session"/>
<jsp:setProperty name="user" property="*"/>

<HTML>
<BODY>
Languages:<%= user.getLanguages()%>
<%FileOutputStream fout;//declare a file output object
PrintStream ps;//declare a print stream object.
try{
out.println("Creating file");
fout=new FileOutputStream("DisplayComments.html");
ps=new PrintStream(fout);
out.println("file created");
ps.println("<html>");
ps.println("<body>");
ps.println(user.getCategory());
ps.println("</body>");
out.println("file created11");
ps.close();
}
catch (Exception e){//Catch exception if any
System.err.println("Error writing to a file " );
}

%>

Can anyone tell me where the file is created?
Thanks,
Sandhya.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A web application has no default directory where files are created, so the exact location is up to the servlet container. You should use an absolute path in the FileOutputStream constructor, so that you can specify where the should go.

By the way, it would be a much better design not to do this in a JSP, but in a servlet or backing bean. JSPs are not meant to include extended Java code sections.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!