8 Replies Latest reply on Sep 15, 2003 9:00 PM by no_ejb

    How to replace a file in a war ?

    IPOz Newbie

      hi,friends
      we are using jboss-3.2.1_tomcat-4.1.24 bundle in linux. The war is deployed successfully.

      A GIF file in /web-app/images dir needs to be changed dynamically by the user. So i use a servlet to do it as below:
      ......
      try {
      Map map = HttpUtil.getUploads(request);
      ByteArrayDataSource ds = (ByteArrayDataSource)map.get("map_file_name");
      if (ds == null || ds.getBytes() == null) { return; } ClassLoader cl = getClass().getClassLoader();

      FileOutputStream fo = new FileOutputStream(
      cl.getResource("images/map.gif").getFile()
      );
      fo.write( ds.getBytes() );
      fo.flush();
      fo.close();

      }
      catch (Exception ex) {
      throw new ServletException(ex);
      }

      but jboss reports:
      javax.servlet.ServletException:
      file:/home/tom/jboss-3.2.1_tomcat-4.1.24/server/default/tmp/deploy/server/default/deploy/omnet-web.war/57.omnet-web.war!/images/map.gif (No such file or directory)
      at com.omnet.web.LocationServlet.doPost(LocationServlet.java:180)
      ...

      any suggestion is appreciated !