Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
    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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh
  • 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
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic