• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

servlet-mapping tag of deployment descriptor  RSS feed

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using tomcat 4.1 server.
I have a servlet named LoginServlet & have defined it in the deployment descriptor as follows:
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>Login.*</url-pattern>
</servlet-mapping>

When I invoke it as: http://localhost:8080/appname/Login.ac
it gives error HTTP-404 URL not found.
But, if i define the url-pattern as *.login & invoke it as
http://localhost:8080/appname/ac.login
it takes me to the corresponding page.

Why does the * behave differently before the . & after the .

If i have an entry like *.* will this work? I am unable to understand why * behaves differently?
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From SRV.11.2 (the servlet spec)


* A string beginning with a �/� character and ending with a �/*� postfix is used
for path mapping.
* A string beginning with a �*.� prefix is used as an extension mapping.
* A string containing only the �/� character indicates the "default" servlet of the
application. In this case the servlet path is the request URI minus the context
path and the path info is null.
* All other strings are used for exact matches only.


The only bullet yours satisfies is the fourth. And there is no page literally named "Login.*", so you get 404.

Basically, you can map an extension (*.foo) or a path (/foo) but not both.
 
Kavita Bopardikar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!