Configuration options - MTDdk/jawn GitHub Wiki

The jawn framework is actually a servlet filter of the type javax.servlet.Filter. Adhering to this standard interface ensures operation of the framework in almost any servlet container.

You can either use it in an embedded Tomcat or Jetty server, or deploy it as a standard war configured in src/main/webapp/WEB-INF/web.xml.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    <display-name>jawn-example</display-name>
    <filter>
        <filter-name>dispatcher</filter-name>
        <filter-class>net.javapla.jawn.RequestDispatcher</filter-class>
        <init-param>
            <param-name>root_controller</param-name>
            <param-value>index</param-value>
        </init-param>
    </filter>
    <filter-mapping>
        <filter-name>dispatcher</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
</web-app>

This is an actual web.xml from a commercial project. It does not need to be any more complicated than this, but it can be, of course.

There is at this point a single parameter you need to initialise when using this project:

  • root_controller - This is the name of the standard controller automatically called by the framework when no specific path is provided, like: http://domain.com/. In this specific example, the IndexController is the default with default action index. It is equivalent of calling http://domain.com/index

Location of the webapp

Conventionally is placed in src/main/webapp, but can practically be anywhere on the disk.

If for an example you want the views to be handled by a front-end developer, the webapp could be placed outside the code base to let him make all changes and only upload new HTML when needed. This separates the view even more from the code, and new functionality could be hot-swap deployed without the need to upload everything within the webapp as well.

The placement of the folder can be seen in Using Jetty.

⚠️ **GitHub.com Fallback** ⚠️