code: protected File filterWebXml( File webXml, File outputDirectory, String applicationName, String playWarId )
          throws IOException
      {
          if ( !outputDirectory.exists() )
          {
              if ( !outputDirectory.mkdirs() )
              {
                  throw new IOException( String.format( "Cannot create \"%s\" directory",
                                                        outputDirectory.getCanonicalPath() ) );
              }
          }
          File result = new File( outputDirectory, "filtered-web.xml" );
          BufferedReader reader = createBufferedFileReader( webXml, "UTF-8" );
          try
          {
              BufferedWriter writer = createBufferedFileWriter( result, "UTF-8" );
              try
              {
                  getLog().debug( "web.xml file:" );
                  String line = reader.readLine();
                  while ( line != null )
                  {
                      getLog().debug( "  " + line );
                      if ( line.indexOf( "%APPLICATION_NAME%" ) >= 0 )
                      {
                          line =
                              line.replace( "%APPLICATION_NAME%", applicationName/* configParser.getApplicationName() */ );
                      }
                      if ( line.indexOf( "%PLAY_ID%" ) >= 0 )
                      {
                          line = line.replace( "%PLAY_ID%", playWarId );
                      }
                      writer.write( line );
                      writer.newLine();
                      line = reader.readLine();
                  }
              }
              finally
              {
                  writer.close();
              }
          }
          finally
          {
              reader.close();
          }
          return result;
      }
docs: used by "war" and "war-support" mojos