File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Servlet Aliasing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Aliasing" Watch "Servlet Aliasing" New topic

Servlet Aliasing

Kumar Vinay

Joined: Sep 29, 2000
Posts: 23
Hi folks,
What exactly is servlet aliasing...can anybody explain me in detail....
Thanx in advance for ur effort and time
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
Wit servlet aliasing the web server maps a request for a particular resource to the servlet class you create. In the servlet 2.2 API this is accomplished in the web.xml file for a particular applications.
For example, the following maps a request for "" to the NumberSoundServ servlet - as qualified by the full package. It also creates an initialization parameter that will be passed to the servlet init method.
<servlet><servlet-name></servlet-name> <servlet-class>com.JSPbook.Chap04.NumberSoundServ</servlet-class>
<param-name>basepath</param-name> <param-value>c:/tomcat/webapps/Root/JSPbook/Chap04/sounds

author of:
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Servlet alias means you are calling a servlet with another name of your choice at the URL.
It is always good idea to keep the servlets inside packages and deploy. Assuming you have a LoginServlet kept like this.
It need not have this much depth level. What I use is one level depth like MISApp.LoginServlet.
So when we make a request from a url we write like this.
Instead of calling the Servlet with its package name like above everytime, we may choose to have a simple name like this

This means we made an alias for MISApp.LoginServlet as just 'LoginServlet'. For this we have to edit web.xml file and add entries for LoginServlet as Bill stated above. If the servlet container supports Servlet 2.2 API web.xml is the place to write all aliases for servlets.
maha anna
[This message has been edited by maha anna (edited December 09, 2000).]
subject: Servlet Aliasing
It's not a secret anymore!