I don't won't to show name of my servlet. so i changed <servlet> <servlet-name>Helloabc</servlet-name> <servlet-class>HelloWorld</servlet-class> </servlet> and accessed it using http://localhost:8080/abc/servlet/helloabc 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 http://localhost:8080/abc/hello.html if yes, how ???
Joined: Apr 24, 2002
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: <servlet> <servlet-name>hello</servlet-name> <servlet-class>abc.hello.HelloWorld</servlet-class> </servlet>
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: <servlet-mapping> <servlet-name>hello</servlet-name> <url-pattern>/myhello.html</url-pattern> </servlet-mapping>
You can obtain more information on this by reading the Servlet Specification. You can download the latest specification document here. Happy Reading..!!
Do not let what you cannot do interfere with what you can do !!<br /> <br />SCJP & SCWCD 1.4
Author and all-around good cowpoke
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. Bill