|
|
Home Page
Tips page
University Page
Programming
Debian & Linux
Some works
About me
Del.icio.us Bookmarks
BOINC Combined Statistics
Site Statistics
Contact me sending an e-mail (antispam defense activated)
|
|
|
|
Title: How to map a servlet
Author: Sandro Tosi
Last modified: 2004-08-14
First of all: I'm not an expert in web applications development! My
work it's only about deployment of web apps, and this means even map
servlet.
Following the well-known way of try/mistake/correct and so on, I think
I have found the correct way to map a servlet.
The file <app_path>/WEB-INF/web.xml is the place to map the servlet
(at least in a JBoss environment).
This is what i do to map a servlet:
<servlet>
<servlet-name>[a_name]</servlet-name>
<servlet-class>[full_java_class_name__package.classname]</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>[a_name]</servlet-name>
<url-pattern>[how_servlet_is_called]</url-pattern>
</servlet-mapping>
where
[a_name] has to be a unique name, but it's utility is only to link the
servlet with the servlet-mapping sections.
[full_java_class_name__package.classname] if your servlet is called
LoginServlet and is inside the package
com.asite.asubsection.manager.servlet then here you have to write
com.asite.asubsection.manager.servlet.LoginServlet.
[how_servlet_is_called] the way you refer to the servlet in your web
application, usually
/servlet/com.asite.asubsection.manager.servlet.LoginServlet
Here an example:
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.asite.asubsection.manager.servlet.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/servlet/com.asite.asubsection.manager.servlet.LoginServlet</url-pattern>
</servlet-mapping>
The tab <servlet> creates a map between a unique name and the class
name of a servlet, and the tag <servlet-mapping> associates that
unique name to the way the servlet is called in the code.
|