Defining and Mapping Servlets - JBoss

Ratings:
(4)
Views:0
Banner-Img
  • Share this blog:

 

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:

About Author
Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.


Stay Updated


Get stories of change makers and innovators from the startup ecosystem in your inbox