Hi, I started the tomcat and pulled up the HelloWorldServlet on the browser. After that I shut it down and opened the web.xml for that application and changed the servlet-name and servlet-class element to 'httpTest'. I also put the httpTest.class file in the folder webapp>AppFolder>WEB-INF>classes. Now when I opened a new browser and refreshed the previous URL it still pulled up HelloWorlServlet. And the new URL with httpTest will not load anything- gives 404 error. Can any one explain me why is it doing that? thanks in advance. suresh SCJP 1.4
Now when I opened a new browser and refreshed the previous URL it still pulled up HelloWorlServlet. And the new URL with httpTest will not load anything- gives 404 error.
I am going to guess that you are using a URL with the /servlet/ syntax and that the web application has the "invoker" servlet turned on. In that case, Tomcat is totally ignoring the web.xml because it sees "/servlet/" and routes the request through the invoker servlet. Bill
Yes... The invoker is on and Iam trying to access using servlet/servName Now what would be the solution for the tomcat to use the web.xml for each webapp than to use the invoker??? Please help... thanks, suresh SCJP 1.4
Joined: Oct 30, 2003
Hi Preeti, I have figured out the problem. I guess we were using the invoker which was preventing the webapp's web.xml from being used for servlet loading[This is implicit loading]. Now if we want to use the explicit loading then we have to add the '<servlet-mapping>' element in our web.xml. So that when you request the servlet using http://servername ort#/webappName/<url-pattern>(as mentioned in web.xml for each servlet) it will use the web.xml file inside the webApp/WEB-INF/ folder to load the servlet. FYI my web.xml looks like:- //-------------------------------------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app> <servlet> <servlet-name>surtest</servlet-name> <servlet-class>tester.surtest</servlet-class> </servlet> <servlet> <servlet-name>logintest</servlet-name> <servlet-class>log.loger.logintest</servlet-class> </servlet>
<servlet-mapping> <servlet-name>surtest</servlet-name> <url-pattern>/sur1</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>logintest</servlet-name> <url-pattern>/sur2</url-pattern> </servlet-mapping> </web-app> //-------------------------------------------- Where surtest.class file is located :- webapp/WEB-INF/classes/tester and logintest.class is located :-webapp/WEB-INF/classes/log/loger You will invoke the servlet using :- http://servername ort#/webapp/sur1 & http://servername ort#/webapp/sur2 Do not worry about uncommenting/commenting the invoker. I just left it uncommented. You don't even need to add the contextpath in server.xml. Hope that help... You can refer to this document in case you get stuck http://test.javaranch.com/wiki/view?InvokerServlet suresh SCJP 1.4