aspose file tools*
The moose likes JSP and the fly likes How to include just created files. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "How to include just created files." Watch "How to include just created files." New topic
Author

How to include just created files.

Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
Having a little problem, think I know whats going on, but not how to fix it.

I have a JSP with a form that takes user input, calls a servlet that generates a CSS file and a 'body' html page. I then redirect the user to a JSP page which <jsp:include..>s the CSS and the body in it to make a page based off of the user input.

I got it to create the CSS and body html file fine, but when I include it on the JSP page, it shows the previous content, as in the state of the CSS and body html file when it was deployed. How do I get it to include the just created pages, and not what was there at deploy time?

I am using the NetBeans IDE bundled with Tomcat.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Most immediately, I'd do a View Source of the HTML being sent to the browser to see why it's not doing what you want.

But longer term, I'd step back and ponder why you are doing this as a two step process. Rather than create files just so you can turn around and include them, why not stream the generated content directly and cut out the middle-man?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
When viewing the page source, it isn't taking in the 'just created' version of the files, its taking the 'at deploy time' files. The files them self are being written/updated correctly. Its just the container isn't reading in the current file, its taking what was there at deployment. I thought the <jsp:include..> tag was processed at request time. Is there something I'm missing? How do I get it to display the JSP page with the just created/updated files?


This is a two step process because the users are creating a page of which they can just view again later without having to recreate the page.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

I thought the <jsp:include..> tag was processed at request time


It is. If the files are modified prior to execution of the JSP the updates should be picked up. But this is not anything I've ever tried to do so there may be some internal caching at play. Are you absoultely sure that the new files are in place prior to JSP execution?
Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
Yes, I'm sure. I've opened the files, saw that it was updated correctly, but what is being included is the version of those files at the time of deployment, not the files that are there during the request of the page with the <jsp:include..>. How might I go about getting it to display the current version of the files? Is the issue with the container? Is there some configuring I need to do with Tomcat?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Originally posted by Brett Carty:
I've opened the files, saw that it was updated correctly,


Have you opened the files before or after the request where the previous incarnation gets displayed?

Opening them after-the-fact isn't going to tell us much about any race conditions during the processing of the request.
[ April 21, 2007: Message edited by: Bear Bibeault ]
Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
Here is what happens. A user fills out a form in a JSP page. The action on submission sends it to a servlet. That servlet sends the info to the model, a java class, which makes the CSS and the body HTML files. After the pages are created, the user is redirected to a JSP. That JSP <jsp:include>s the small new CSS and the new body.

The first time the project is deployed, I get an org.apache.catalina.connector.ResponseFacade.sendError(ResponseFacade.java:404) error. When its redeployed every time after that, it displays the previous version of the CSS and body HTML files (the version that was in existence during deployment). My guess is that the container, Tomcat, is putting those files in memory during deployment and ignoring the files at runtime (or that it is now in existence if it previously didn't exist). Is this normal behavior of a container? That the files at runtime are ignored and only files during deployment are used? And more importantly, how do I get it to run correctly so that it includes the files that are there during the request?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Originally posted by Brett Carty:
My guess is that the container, Tomcat, is putting those files in memory during deployment and ignoring the files at runtime (or that it is now in existence if it previously didn't exist). Is this normal behavior of a container?


No, and I doubt that that's the way that Tomcat is behaving.

Where are you creating the files and how are you addressing them from the JSP?
Aron Daburn
Ranch Hand

Joined: Mar 18, 2007
Posts: 36
The files are being placed in a subdirectory of the web folder. This is the include tag for the CSS <jsp:include page="CSS/${param['id']}.html"/>

Maybe with the Netbeans IDE it is copying my project at deployment and placing it in a Tomcat specific location and being ran from there, thus when the new files are created its not in the actual implemented location?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to include just created files.
 
Similar Threads
JSP Form help?
Very strange behaviour with form based login and css file
[SOLVED] CSS not being applied to my JSF?
Placing HTML Element table of INPUT TEXT fields at specified location in the page at run time
JSP page not displaying "