I ran into a similar problem in trying to serve static content with tomcat,
tomcat had trouble retrieving dynamically created content unless it was
already in the webapp at start, at least that was my experience. Since
you're trying to create a jsp, why don't you create one jsp and pass it your
preview data, then return that to the user. Even if tomcat could serve newly
created jsp, i don't see why you'll create a .jsp page every time the user
hits a preview button, one jsp should do. Also you may want to look into
autoDeploy etc.. config properties, there are options you can enable to make
tomcat notice changes in servlet code (including jsp), I am not sure they
apply to newly added JSPs.

On 12/15/06, Carl <[EMAIL PROTECTED]> wrote:

 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: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
"talk trash and carry a small stick."
PAUL KRUGMAN (NYT)

Reply via email to