This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes straing servlet URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "straing servlet URL" Watch "straing servlet URL" New topic

straing servlet URL

jbig zala

Joined: Sep 20, 2004
Posts: 11
Hi Smart Cattles,

I m facing very strange prob with web.xml and servlet names.

I have created context name 'abc' and servlets in abc\WEB-INF\classes folder.
To Access servlet named helloworld i have to use url named

I don't won't to show name of my servlet. so i changed
and accessed it using
but it gives me 404 error.
it works only if i changed servlet-name as HelloWorld again .
Where i mistaken ?
is it possible to access HelloWorld servlet using URL like
if yes, how ???
John Mallavalli
Ranch Hand

Joined: Apr 24, 2002
Posts: 46
Hey Smartie,

You need to do 2 things.
1. In the web.xml, you need to provide a servlet element with the fully qualified class name of the servlet and the name with which you want to access that particular servlet. For example, if you have a servlet class as abc.hello.HelloWorld and if you would like to call it as "hello" then the entry in the web.xml would be as follows:

2. You need to map the servlet for an url path so that the servlet can be accessed. For example, if you want to access this servlet by typing "http://myserver:8080/abc/myhello.html", then you need to add a "servlet-mapping" element in the web.xml as follows:

You can obtain more information on this by reading the Servlet Specification. You can download the latest specification document here.
Happy Reading..!!

- John

Do not let what you cannot do interfere with what you can do !!<br /> <br />SCJP & SCWCD 1.4
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13027
and accessed it using
but it gives me 404 error.

This indicates that you need to read the invoker servlet FAQ.
Books and articles dating from before the invoker was turned off by default in Tomcat must surely be the cause of at least half of all beginner problems.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

"Dev Smart"-

This is your second warning.

Welcome to the JavaRanch! Please adjust your displayed name to meet the

JavaRanch Naming Policy.

You can change it


Thanks! and welcome to the JavaRanch!


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
jbig zala

Joined: Sep 20, 2004
Posts: 11

faqs suggest that i have to uncomment above tags. It have tried, but gives me 404.
what's wrong ?
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

"Quick Learner",
sorry to nag, but your display name still does not meet our requirements

We require display names to be two words: your first name, a space, then your last name. Obviously fictitious names are not allowed.

We appreciate your co-operation.
subject: straing servlet URL
It's not a secret anymore!