This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes I am not understanding the meaning of ../ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "I am not understanding the meaning of ../" Watch "I am not understanding the meaning of ../" New topic
Author

I am not understanding the meaning of ../

Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
<%@ include file="../view.jsp" %>

In this i am not understanding the meaning of ../

I am getting confusion with /, ./ , and ../.

Thanks in advance

swapna
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61089
    
  66

It'a a rather poor practice. It means up in the parent folder; which makes it a page-relative URL. Very fragile.

The URL should not be page relative -- it should start with a / that represents the context root.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
Bear Bibeault wrote:It'a a rather poor practice. It means up in the parent folder; which makes it a page-relative URL. Very fragile.

The URL should not be page relative -- it should start with a / that represents the context root.


Thanks bear for the prompt answer. But i am not clear. Can you elaborate please ?

Thank you in advance
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61089
    
  66

You'll have elaborate on what you are not clear on.
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Swapna wrote: <%@ include file="../view.jsp" %> In this i am not understanding the meaning of ../


When you write ../view.jsp you are instructing the current jsp to include a file by the name of view.jsp located in a directory that is one level up from the directory in which your current jsp is located.


~ Mansukh
Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
Mansukhdeep Thind wrote:
Swapna wrote: <%@ include file="../view.jsp" %> In this i am not understanding the meaning of ../


When you write ../view.jsp you are instructing the current jsp to include a file by the name of view.jsp located in a directory that is one level up from the directory in which your current jsp is located.


Thank you very much mansukhdeep. Now i got it

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

You are always welcome. :)
Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
Mansukhdeep Thind wrote:You are always welcome. :)


Hi mansukhdeep, whats the difference between ./ and / then ?

thanks in advance

swapna
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

Greetings Swapna,

Well ./ ( dot slash ) means the current directory and / (slash) means the root directory of the context.


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61089
    
  66

And, once again, page-relative URLs that employ ../ and ./ should never be used. It's just asking for trouble.
Swapna latha
Ranch Hand

Joined: Dec 18, 2011
Posts: 70
Bear Bibeault wrote:And, once again, page-relative URLs that employ ../ and ./ should never be used. It's just asking for trouble.


Thank you very much saif and bear. Out of curiosity i would like you (bear) to ask that why it should not be used . Whats the trouble with page-relative URLs ?

Thanks in advance

swapna
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61089
    
  66

They are fragile. Any changes outside the page could cause the page to stop working correctly, and it makes refactoring the structure of a web app much harder. Maybe not a problem when you only have one page, but as soon as a web app starts growing, those are the kind of problems that can become a huge headache.

Using server-relative addresses is much more robust.
 
Don't get me started about those stupid light bulbs.
 
subject: I am not understanding the meaning of ../