Two Laptop Bag*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Regarding URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Regarding URL " Watch "Regarding URL " New topic
Author

Regarding URL

Kapil Mishra
Greenhorn

Joined: Oct 04, 2009
Posts: 25
hello friends,i have one doubt regarding URL.

On page 129 of HFJS,the something written like-"The getResourceAsStream() requires you to start with a forward slash (“/”) , which represents the root of your web app. "

while on page 136 there is-The forward slash at the beginning means “relative to the root of this web Container”.

So please anyone clarify it,what does this forward slash mean in servlet and wat in DD......



SCJP 5,SCWCD 5
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9321
    
  17

Both mean the same thing to me. A forward slash in the beginning means the path is to be interpreted as starting from the web app root folder. So if you have a value in DD which is /jsp/my.jsp and the web app root folder is myApp, then the value in DD will mean myApp/jsp/my.jsp...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Kapil Mishra
Greenhorn

Joined: Oct 04, 2009
Posts: 25
hi ankit thnx for reply...

but i think root of web container means outside of your app means in webapps folder of tomcat directory...and root of app means your app directory....

correct me if i am wrong....

Thnxx
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3860

Kapil Mishra wrote:
but i think root of web container means outside of your app means in webapps folder of tomcat directory...and root of app means your app directory....

I think you are talking about "response.sendRedirect()" ? In that case if the relative URL starts with "/" then the URL being built will be relative to the web container.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Amru Jahagirdar
Ranch Hand

Joined: Sep 16, 2009
Posts: 39
meaning of both the sentences is same.
root of the web container here, means with respect to your web application.

Anything you specify as '/PathToTheFile' is interpreted as

'WebApplicationName/PathToTheFile'
Kapil Mishra
Greenhorn

Joined: Oct 04, 2009
Posts: 25
yes Vijitha,you got it....

In response.sendRedirect() "/" means relative to container while in other, "/" means relative to application..

I want to know why this inconsistency about this forward slash "/" there ??
Darryl Smith
Greenhorn

Joined: Aug 06, 2010
Posts: 5
I am using the method endodeURL also with a / as the argument and this is also generated a URL that is the root of the web container. The spec mentions nothing regarding where this method should be relative to.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Regarding URL