Defining and Mapping Servlets -JBoss

In WEB-INF/web.xml file: Define a servlet with <servlet> where <servlet-name> points to a fully qualified <servlet-class> Optionally initialize with <init-param>-s Optionally <load-on-startup> Map a defined servlet with <servlet-mapping> where <url-pattern> points to previously specified <servlet-name> Map under multiple <url-pattern>-s if needed

<servlet>

<servlet-name>IPLoggerServlet</servlet-name>

<servlet-class>example.servlet.IPLoggerServlet</servlet-class>

<init-param>

<param-name>file</param-name>

<param-value>/WEB-INF/ip.log</param-value>

</init-param>

<load-on-startup>2</load-on-startup>

</servlet>

<servlet-mapping>

<servlet-name>IPLoggerServlet</servlet-name>

<url-pattern>/ip</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>IPLoggerServlet</servlet-name>

<url-pattern>/logmyip</url-pattern>

</servlet-mapping>

Defining and Mapping Filters in Jboss In WEB-INF/web.xml file:

  1. Define a filter with <filter> where <filter-name> points to a fully qualified <filter-class>

    1. Optionally initialize with <init-param>-s

  2. Map a defined filter with <filter-mapping> where <url-pattern> points to previously specified <filter-name>

    1. Map under multiple <url-pattern>-s if needed
    2. Map with /* to apply to all requests

<!ELEMENT filter (icon?, filter-name, display-name?, description?, filter-class, init-param*)>

<filter>

<filter-name>Logger</filter-name>

<filter-class>example.servlet.AccessLogFilter</filter-class>

</filter>

<!ELEMENT filter-mapping (filter-name, (url-pattern | servlet-name))>

<filter-mapping>

<filter-name>Logger</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

To Get in Depth Knowledge on JBoss Click On: