java - Servlet 3.0 without a WAR file? -
is possible launch webapp altogether with:
1) no war file:
http://stephenh.github.io/2009/01/10/war-less-dev-with-jetty.html http://www.jamesward.com/2011/08/23/war-less-java-web-apps
2) no web.xml (i.e., servlet-3.0)
3) embedded web container (e.g., tomcat or jetty...)
example project: https://github.com/jetty-project/embedded-servlet-3.0
you'll still need web-inf/web.xml
, it can empty. servlet support level , metadata-complete flags can known.
example: empty servlet 3.0 web.xml
<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="false" version="3.0"> </web-app>
then can follow embedme.java example on how set up.
public class embedme { public static void main(string[] args) throws exception { int port = 8080; server server = new server(port); string wardir = "target/sample-webapp-1-snapshot"; webappcontext context = new webappcontext(); context.setresourcebase(wardir); context.setdescriptor(wardir + "web-inf/web.xml"); context.setconfigurations(new configuration[] { new annotationconfiguration(), new webxmlconfiguration(), new webinfconfiguration(), new taglibconfiguration(), new plusconfiguration(), new metainfconfiguration(), new fragmentconfiguration(), new envconfiguration() }); context.setcontextpath("/"); context.setparentloaderpriority(true); server.sethandler(context); server.start(); server.join(); } }
Comments
Post a Comment