Hi. I have a servlet where sometimes it's not necessary to output html in
bits and pieces and reading in an html file and writing out that data would
be easier. For example in my servlet I have a method like this:
private void ExportHTML(HttpServletRequest request, HttpServletResponse
response, String fName)
throws ServletException, IOException
{
File fileIn = null;
FileInputStream streamIn = null;
try
{
fileIn = new File(fName);
streamIn = new FileInputStream(fileIn);
byte[] data = new byte[(int) fileIn.length()];
streamIn.read(data);
streamIn.close();
response.setContentType("text/html");
PrintWriter textOut = response.getWriter();
textOut.println(new String(data));
textOut.close();
}
catch (Exception e)
{
OutPutError(response, "Exception thrown!!!");
}
System.out.println("ExportHTML finished");
}
and it will dump out any html page I tell it to.
I'm just wondering if there is anything wrong doing it like
this...especially if there would be negative side effects considering that
the servlet would be handling multiple users and thus multi threaded?
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html