Welcome

Running Jetty Embedded Continued

For some time ago, i had mentioned about running jetty embedded. This time while I am still running it embedded, I need to set “WebContent” path from inside classpath of the application. It will reside next to my test class. As I don’t want to couple my test case with the absolute path of the project, I first find a way to to get absolute path of my test case.

String path = getClass().getResource(".").getPath();

The rest is very similar to my previous post…I just replaced setWar() with setResourceBase(), and setDefaultDescriptor() with setDescriptor().

webapp.setResourceBase(path + "/WebContent");
webapp.setDescriptor(path + "/WebContent/WEB-INF/web.xml");

BTW, another quick note is, in order to enable JSP support, you will need to copy jars in lib/jsp-2.0 or jsp-2.1 coming with jetty dist.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.