Jetty: unzip .war to a specific folder

I need to run Jetty, point to the war file and unzip Jetty to a specific location. The general behavior of Jetty is to take the TEMP directory or JETTY_HOME / working directory and unzip the war file into a subfolder named like this: jetty-HOST-PORT-CONTEXT.war -_- any- This is absolutely inappropriate for our environment, because part of PORT is random. The war file must be unpacked by Jetty, and the destination must be 100% flexible.

Is it possible? Please advise. Jetty is not my area of ​​expertise, forgive me if the question is lame or trivial, however googling did not help much.

Many thanks!

+5
source share
2 answers

. Ive Jetty :

int port = 8080;
String context_path = "/";
File tmp_directory = "C:\\some-custom-path\\";
String war_path = "C:\\path-to-a\\file.war";

WebAppContext app = new WebAppContext();
app.setContextPath( context_path );
app.setWar( war_path );
app.setTempDirectory( tmp_directory );

Server server = new Server( port );
server.setHandler( app );
server.start();
server.join();

app.setTempDirectory Jetty war-file . , .

+5

( , - jetty wiki) . setWar.

    Server server = new Server(8080);
    WebAppContext webapp = new WebAppContext();
    webapp.setContextPath("/");
    webapp.setWar(jetty_home+"/webapps/testlocation/");
    server.setHandler(webapp);
+1

All Articles