Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Creating new files in an existing deployed war file.

Reply
Thread Tools

Creating new files in an existing deployed war file.

 
 
Ben Jessel
Guest
Posts: n/a
 
      11-03-2003
I have a web application that is contained in a war file. I have a
requirement to generate an xml file ( will be an rss field ), that can
be accessible at a given url within my web application. This file
could be quite big, so I can't just generate it on the fly per
request. Nor can I cache it in session data.

I'd prefer to deploy my application in war, rather than exploded-war
format ( portability being a large concern.... ), however given I need
to generate this xml file and save it in a directory of my web-app
root, I think my only option is to revert to exploded war use.

Is there any way of programatically creating/updating a file within
say, the my-app war from a servlet in the war itself?

My alternative strategies are

1) saving the xml to the database ( something that the purist in me
hates the idea of ).
2) pushing the file to another server.

Thanks
 
Reply With Quote
 
 
 
 
Ben_
Guest
Posts: n/a
 
      11-03-2003
You needn't necessarily create it in the root of your project: you can
create it somewhere else (File.createTempFile) and create a servlet to
stream the actual content.

You could also create it under the root of your app (with
ServletContext.getRealPath) but you must ensure your WAR file is exploded.
If not, you could zip a new entry in the War file with the Zip API (will the
purist you claim to be like this ? )).


 
Reply With Quote
 
 
 
 
John C. Bollinger
Guest
Posts: n/a
 
      11-04-2003
Ben Jessel wrote:

> I have a web application that is contained in a war file. I have a
> requirement to generate an xml file ( will be an rss field ), that can
> be accessible at a given url within my web application. This file
> could be quite big, so I can't just generate it on the fly per
> request. Nor can I cache it in session data.
>
> I'd prefer to deploy my application in war, rather than exploded-war
> format ( portability being a large concern.... ), however given I need
> to generate this xml file and save it in a directory of my web-app
> root, I think my only option is to revert to exploded war use.
>
> Is there any way of programatically creating/updating a file within
> say, the my-app war from a servlet in the war itself?
>
> My alternative strategies are
>
> 1) saving the xml to the database ( something that the purist in me
> hates the idea of ).
> 2) pushing the file to another server.


How about

(3) Generate it at application startup or on the first request, and
store it in the temp directory provided to you by the servlet container.
Create a servlet, mapped to the designated URL, that delivers the data.

That is completely independant of deployment format, does not depend on
another server, and should be as efficient as you can hope for given
your requirements.


John Bollinger


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
The War Criminal about to Start another War Ctrl¤/Alt¤/Del¤ Computer Support 30 11-30-2010 02:45 PM
Web service is not creating Log files when deployed in a server SenthilVel ASP .Net Web Services 0 03-08-2007 03:26 PM
Serve static files with Apache from a .WAR file deployed in JBoss? Josh McCulloch Java 1 08-19-2004 10:55 PM
Access files in deployed war from within JSP? Java Job Java 1 08-05-2004 08:53 PM
org/apache/fop/apps/XSLTInputHandler not found in deployed war !! Manoj Nair XML 0 06-08-2004 05:09 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57