Environment: Tomcat 5.5.17, Windows XP
Background: I have a jsp page that contains a javascript rich text editor that
I use to create snippets of HTML code that are stored in a database and later
displayed on other pages. Since the snippets can contain some custom tags, I
have a 'Preview' button that reads the snippet directly from the editor, reads
a 'preview' jsp file from the file system, places the snippet in the correct
place in the file, writes the 'preview' file with the snippet to a temporary
file and opens a new window (using javascript) which requests the temporary
page from Tomcat.
Problem: I can see the newly created temporary file in the file system. I can
open it with an editor and it is all good. But, Tomcat returns a 404 error for
approximately one minute and then will serve the page upon hitting only the
refresh.
Analysis: I suspect the system is holding onto the newly written file until it
hits some timeout but I have tried everything I can think of to make certain
the file has been 'released'. The relevent parts of the copy process:
try {
File tempFile = File.createTempFile("preview", ".jsp", new
File("C:/projects/EtrakWebApp/web/jsp/tempfiles"));
// read the preview jsp
FileWriter fw = new FileWriter(tempFile);
File infile = new File(destinationDir+"preview.jsp");
if( infile.exists() )
{
FileReader fr = new FileReader(infile);
BufferedReader in = new BufferedReader(fr);
while(true)
{
String line = in.readLine();
if( line==null )
break;
System.out.println("line "+line );
// insert the text
if( line.contains("insert_preview_text") )
{
fw.write(previewText+"\n");
}
else {
fw.write(line+"\n");
}
}
fr.close();
in.close();
}
fw.flush();
fw.close();
fw = null;
}
catch (FileNotFoundException fnf)
{
fnf.printStackTrace();
}
catch (Exception ex)
{
ex.printStackTrace();
}
return returnFileName;
Anyone have any ideas?
TIA,
Carl Kabbe
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.15.19/587 - Release Date: 12/14/2006
---------------------------------------------------------------------
To start a new topic, e-mail: [email protected]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]