Bookmark Topic Watch 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
There are a number of types of paths used in Java web applications, each of which may be required or preferred in different situations:

absolute path, starts with the protocol and is an absolute locator for a resource. It is not relative to anything and identifies the protocol (scheme), domain, and resource path.

Examples:


protocol-relative path, starts with "//" and is relative to the current protocol (or scheme) so that an otherwise absolute URL can use the same scheme as the current path.

Example:


server-relative path, starts with the context path. Preferred for URLs initiated from the browser (e.g. images, script files, stylesheets, form actions, and so on).

Examples:


context-relative path, starts with "/" and is relative to the context base. Paths starting with "/WEB-INF" are a good example. Preferred for paths used on the server for resources within the same web app (includes, forwards, etc).

Examples:


page-relative path, relative to the current URL path. Anything that starts with "." or ".." or a file or folder name relative to the current path. These are fragile because they are relative to something that may change (current path) and should not be used in Java web applications anyplace that a server-relative or context-relative path can be used. An example of an exception is paths within stylesheets which cannot be easily prefixed programmatically with the context path.

Examples:



JspFaq ServletFaq
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic