The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes about path prefix mappings, default mappings Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Web Component Certification (SCWCD/OCPJWCD)
Reply Bookmark "about path prefix mappings, default mappings" Watch "about path prefix mappings, default mappings" New topic
Author

about path prefix mappings, default mappings

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Hi,
Could anyone explain path prefix mappings and default mappings by giving some examples? Thanks in advance.
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Could you please specify a context in which you encountered this. Would make it easy for me to come up with an example, to relate to what you are looking for.
regds.
- madhav


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208

For the above case, now we can use: http://localhost/sth.html
to map to myServlet.
If we want to use path prefix mapping, we
have to do sth like this:

Does that mean we can map to myServlet like this now?
http://localhost/sth/whatever
If we want to use default mapping, we have to do sth like this:

The above code will ID the default servlet for web-app. How do we define our default servlet? and how to use url to locate myServlet in this case?
Thanks in advance.
rick
[ April 11, 2002: Message edited by: Peter den Haan ]
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Does that mean we can map to myServlet like this now?
http://localhost/sth/whatever
Yes. This facility is used a lot to implement virtual directories: e.g. a request for http://localhost/sth/secret/mydocument.doc would fire the "sth" servlet. This servlet then examines the extra path info ("/secret/mydocument.doc") and can for example retrieve the document from a database. That way, you can make the contents of a database (or a JNDI tree or an XML file or...) look like a set of directories and documents on a web server.

[...] How do we define our default servlet? and how to use url to locate myServlet in this case?
I don't quite understand the question? You define the default servlet as usual - by defining a servlet called "myServlet". Any request to the server will invoke the default servlet, unless there is a more specific servlet mapping for that request.
- Peter
[Yuk. I don't know what happened to the quoting - hopefully this will be better]
[ April 11, 2002: Message edited by: Peter den Haan ]
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Gracias, Peter:
We depend on gurus like Peter, Clark, Carl, Alex, madhav, etc (sorry that I cannot remember all).
Folks, never take it for granted. I have not passed the exam yet, but I know these good folks have saved my time in my slow world. Merci.
[ April 11, 2002: Message edited by: rick collette ]
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Originally posted by Peter den Haan:
Yes. This facility is used a lot to implement virtual directories: e.g. a request for http://localhost/sth/secret/mydocument.doc would fire the "sth" servlet. This servlet then examines the extra path info ("/secret/mydocument.doc") and can for example retrieve the document from a database. That way, you can make the contents of a database (or a JNDI tree or an XML file or...) look like a set of directories and documents on a web server.
[/qb]

Don't miss this one.
[ April 11, 2002: Message edited by: Axel Janssen ]
 
 
subject: about path prefix mappings, default mappings
 
Threads others viewed
mock question regarding servlet mapping
servlet mapping in Tomcat 6.0 - stack overflow
servlet mapping question
About servlet-mapping
servlet-mapping / url-pattern: / vs /*
IntelliJ Java IDE

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture