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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis
  • Mark post as helpful
  • send pies
  • 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
 
Would you turn that thing down? I'm controlling a mind here! Look ... look at the tiny ad ...
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!