Closed Pasupathi-Rajamanickam closed 5 years ago
Depends on how you deploy. As standalone, you could try defining the context path in META-INF/context.xml
, but I'm not certain if it will have any effect. Deploying as a WAR file, the context path will be determined by the file name, or can be configured in the server configuration.
@jakaarl I thought sparkjava is java based framework, I built runnable jar out of it and tried to run. That's the way I'm more inclined to. No more war files 😄 I can't go back to old architecture.
Unfortunately you can't set a context path using the embedded Jetty server.
@tipsy as far I know it's easy to setup. Maybe it's not feasible in sparkjava?
ContextHandler context = new ContextHandler();
context.setContextPath( "/hello" );
context.setHandler( new HelloHandler() );
Server server = new Server(serverPort);
server.setHandler(context);
server.start();
server.join();
It's pretty easy, yes. There is a PR for it, but it's been open for years.
I'm looking for an option to set context path all request, I know I can append context path for each and every request that I'm mapping, but what do I do for static folders?
Context path is super critical when we run app behind nginx. So please let me know if there is a way to achieve this scenario.