hi, Can anybody guide me in configuring servlets in a new context other than the examples context , on tomcat4. when i try to invoke a servlet, file not found exception is occurring. the structure of the web.xml is like this <servlet> <servlet-name> UpdateLicense </servlet-name> <servlet-class> UpdateLicense </servlet-class> </servlet>
yes i have mapped it as <servlet-mapping> <servlet-name> UpdateLicense </servlet-name> <url-pattern> / UpdateLicense </url-pattern> </servlet-mapping> even then iam not able to invoke it it still gives me the file not found exception
Don't bother uncommenting that servlet/* mapping. It's not a 'best practice' way of invoking servlets!
the servlet mappings for each application should be in that application's web.xml. p.s. - if you tried to put a servlet mapping in server.xml, it would throw a parsing exception. They're not allowed in this file.
Is there a space between your '/' and UpdateLicense? (there shouldn't be).
Also... moving this from Servlets -> Apache/Tomcat
below is the structure of the web.xml of the application,iam trying to deploy
<?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>HelloWorldExample</servlet-name> <servlet-class>test.HelloWorldExample</servlet-class> </servlet> </web-app> while invoking iam using the url http://localhost:8080/test/servlet/HelloWorldExample the context tag in server.xml is <Context path="/test" docBase="test" debug="0" reloadable="true" crossContext="true"/> i still am getting The requested resource (/test/servlet/HelloWorldExample) is not available.
Look in your logs. Looking at your web.xml I see that some elements namely description and name are missing. I'm not sure of their order(It matters!!). I'm guessing the xml parser has thrown a parser exception during validation. If thats the case, try adding those elements in as they are mandatory and they should be in the correct order.