In web.xml, I have following xml <servlet> <servlet-name> CompressionFilterTestServlet </servlet-name> <servlet-class> compressionFilters.CompressionFilterTestServlet </servlet-class> </servlet> <servlet-mapping> <servlet-name> CompressionFilterTestServlet </servlet-name> <url-pattern> /CompressionTest </url-pattern> </servlet-mapping> Instead of calling servlet http://localhost:80/CompressionFilterTestServlet, I can use http://localhost:80/CompressionTest. Is that what <servlet-mapping> means?
the short answer is yes, but I have some comments about it. you�re not required to write the port if its 80, that�s the default for your browser, so http://localhost/CompressionTest should be fine, I allways deploy my servlets in a war file and doing so I have to write the name of the war in the url: ex: you have build a example.war and packaged your servlet in it, you should do: http://localhost/example/CompressionTest I can�t remember now how to do if you deploy your servlet without packagin it in a war file. regards.
posted 18 years ago
Main application of Servlet mapping is you can make your Servlet to be invoked for different patterns of the request. for ex: <servlet-mapping> <servlet-name> CompressionFilterTestServlet </servlet-name> <url-pattern> /CompressionTest/* </url-pattern> </servlet-mapping> Then all the urls like http://<webserver>/<contextPath>/CompressionTest/ANYTHINGHERE will invoke CompressionFilterTestServlet servlet, irrespective of the value of the ANYTHINGHERE Sridhar
If what SridharS is saying is TRUE, then thats a new learning for me. Thanks Manish
posted 18 years ago
Hi, this is taken from the servlet2.3 specs pg.77 Consider the following set of mappings: The following behavior would result: Table SRV.11-1 Example Set of Maps path pattern | servlet /foo/bar/* | servlet1 /baz/* | servlet2 /catalog | servlet3 *.bop | servlet4 Table SRV.11-2 Incoming Paths applied to Example Maps incoming path servlet handling request /foo/bar/index.html | servlet1 /foo/bar/index.bop | servlet1 /baz | servlet2 /baz/index.html | servlet2 /catalog | servlet3 /catalog/index.html | �default�servlet /catalog/racecar.bop | servlet4 /index.bop | servlet4 regards. [This message has been edited by Marcos Maia (edited October 24, 2001).]
Something about .... going for a swim. With this tiny ad ...