-
1. Re: How to replace a file in a war ?
ipozeng Sep 9, 2003 7:39 PM (in response to ipozeng)Why can NOT i get any answer ?!
donot you think it is a foolish question ? even so i still need to know the answer.
thanks in advance ! -
2. Re: How to replace a file in a war ?
schmidts Sep 10, 2003 1:40 AM (in response to ipozeng)I wouldn't recommend on-the-fly replacement of files in deployed WARs, even if it worked.
Why not store uploaded graphics in the filesystem or in a database (and maybe caching static content in filesystem)? -
3. Re: How to replace a file in a war ?
ipozeng Sep 10, 2003 3:10 AM (in response to ipozeng)thanks for your answer first !
>>Why not store uploaded graphics in the filesystem
The reason is that we donot know the folder which will be used by our users.Of course we can force the users to create a specified folder used to put our uploaded graphics ?!
>>i n database
it is another choice
regards! -
4. Re: How to replace a file in a war ?
ipozeng Sep 10, 2003 3:21 AM (in response to ipozeng)try {
Map map = HttpUtil.getUploads(request);
ByteArrayDataSource ds = (ByteArrayDataSource)map.get("map_file_name");
if (ds == null || ds.getBytes() == null) {
return;
}
FileOutputStream fo = new FileOutputStream("/tmp/map.gif");
fo.write( ds.getBytes() );
fo.flush();
fo.close();
}
catch (Exception ex) {
throw new ServletException(ex);
}
then the file is uploaded into /tmp successfully. However the /tmp is NOT under the webapp context so that the following code will not work:(
<image xlink:href="/tmp/map.gif" x="0" y="0" width="100%" height="100%" onmouseover="hideMenu(evt);"/>
then how to replace map.gif in a webapp ??? -
5. Re: How to replace a file in a war ?
schmidts Sep 10, 2003 5:08 AM (in response to ipozeng)You could create a directory "images.war" in the deploy-directory and put all your images there.
Another possible solution is to configure the webcontainer to serve content from outside the WAR: http://www.coredevelopers.net/technology/jetty/jetty-jboss-faq.jsp#I_want_to_serve_content_from_outside_a -
6. Re: How to replace a file in a war ?
ipozeng Sep 11, 2003 12:41 AM (in response to ipozeng)That is great ! why donot i get it ?
thank you very much! -
7. How to construct the FileOutputStream ?
ipozeng Sep 11, 2003 12:58 AM (in response to ipozeng)Now the map.gif has been uploaded into images.war/ successfully.However i am not sure what is the best way to construct FileOutputStream ?
One way i think is configure the absolute path in our configuraution file as below:
/home/..../images.war
then
FileOutputStream fo = new FileOutputStream(imageDir);
Do there exsit any other way ?
String pathname = getServletContext().getrealPath("/") always rturn null :(
thanks! -
8. Re: How to construct the FileOutputStream ?
no_ejb Sep 15, 2003 9:00 PM (in response to ipozeng)In JBoss there is a non-portable way which is using ServerConfigLocator class to get ServerConfig class. After that you can call getServerBaseDir(), you can append "deploy" after that. It will be the directory where you dropped your war to.
Again, I used it only in JBoss related part of the code and I am sure it is release dependent (in my case) it is 3.0.2.