JBridge

JBridge: Certification Question Of The Day

JBridge Home >> Certification Questions >> Question for Sunday May 11th 2003 Sunday May 11th 2003

Suppose the following servlet mapping is set up for a web application called “music”:

<servlet-mapping>
	<servlet-name>PlayPiece</servlet-name>
	<url-pattern>/PlayPiece/*</url-pattern>
</servlet-mapping>
Which of the following are true statements? (2 correct answers)



A Given a request URL of http://myHost/music/PlayPiece, the context path would be ‘music’.
B Given a request URL of http://myHost/music/PlayPiece/requiem, the path information would be ‘/requiem’.
C Given a request URL of http://myHost/music/PlayPiece, the servlet path would be ‘/PlayPiece’, and the path information would be null.
D Given a request URL of http://myHost/music/PlayPiece/requiem, the real path information would be ‘//myHost/music/PlayPiece'
Page down for the answer...











































The Answer

B and C are the correct answers.
A is almost right, but the context path would have to begin with a forward slash (thus: ‘/music’).
D is wrong on two counts. The real path would include ‘requiem’ at the end (the path information is not stripped off when finding the real path). Furthermore, the real path information would give the full path within the file system where the resource ‘PlayPiece\requiem’ is located (e.g. ‘C:\Java\jakarta-tomcat-4.1.18\webapps\music\PlayPiece\requiem’ given a Windows directory structure). Although ‘//myHost/music/…’ could represent the beginning of a true file path on the web server, it’s both insecure and very unlikely.


EMail: dbridgewater@jbridge.co.uk
Phone: +44 (0)1943 877414
Fax: +44 (0)1943 877414
Mail: David Bridgewater, Willow Dene, Bradford Road, Menston, Ilkley, West Yorkshire, LS29 6ED, UK
Copyright © 2003 David Bridgewater. All rights reserved.