• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relative Path

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you use relative path like "/hello.jsp". Is it relative to Servlet Context, web app root or server root???

What is a difference between relative path and non-relative path? Also, what is a virtual path???

COuld somebody please explain these concepts?

Thanks,
M Abidi.
 
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When u something like
http://localhost:8080/hello.jsp
It is coming from ROOT application

When u something like
http://localhost:8080/app1/hello.jsp
It is coming from app1 application.

It is relative to the web app you are in. (like in 2nd case, it is app1)
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are three types of paths:
1) absolute path: starts with protocol name, then optional port and then server name. "http://myserver.com/myapp/my.jsp" is an absolute path
2) context-relative path. It starts with /. Then follows a path to the resource relative to the application context. "/my.jsp" is a context-relative path.
3) resource-relative path. Starts with the path to the resource relative to the current resource (such as page or servlet or file). "my.jsp" is a resource-relative path. "./my.jsp" also is also a resource-relative path

The difference between relative paths can be cleared by the text, in which they are used.

Virtual path is a path to the resource, created by means of the server. (Typical examples - by using url-pattern).
[ August 15, 2005: Message edited by: Sergey Tyulkin ]
 
Sehrish Hasan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replying to my post.

I am still confused. What is the differenc between servlet context root and servlet container root? Do they both refer to web app root??

So basically, Relative Path starting with / is relative to the web app root

Relative path not starting with / is relative to the current resource.

Also, "./foo.html" and "foo.html" has the same effect.

If what I wrote above is true then how do you write a path relative to the ROOT directory of the tomcat???
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is special kind of web application - ROOT web application, that can be reached with empty context root. (something like www.mycompany.com - without /myapp/)
Anyway, you cannot reach tomcat's root directory! You can reach only those resources, which are stored in your application's directory. And ROOT application (although its context path is "/") also has its own directory, that can be found under webapps subdirectory in the Tomcat's directory. The directory's name is also "ROOT".
And you can reach any resource from this directory, if your application is deployed in this directory.
 
Sehrish Hasan
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can somebody please explain the difference between servlet context root and servlet container root? Do they both refer to web app root??

Thanks,
M Abidi.
 
Sergey Tyulkin
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We are talking about web applications, right?
So servlet context root is root directory of the current web application.
And for web applications there's no notion of "servlet container root".
But you must remember, that servlet container can have ROOT (or default) web application. It's an ordinal web application, with some different behaviour in distributed environment.
I think, the authors better use "default web application" instead of "ROOT" web application
reply
    Bookmark Topic Watch Topic
  • New Topic