How URLs Are Interpreted

One thing that can be confusing in a JSP-based application is the different types of URIs used in the HTML and JSP elements. The confusion stems from a combination of conflicting terms used to describe URIs in the HTTP, servlet, and JSP specifications, as well as the fact that some types of URIs are interpreted differently in the HTML and the servlet world.

In HTML, URIs are used as attribute values in elements like <a>, <img>, and <form>. JSP elements that use URI attribute values are the page, include, and taglib directives and the <jsp:forward> and <jsp:include> actions. Custom actions can also define attributes that take URI values.

The HTTP/1.1 specification (RFC 2616, with more details in RFC 2396) defines a Uniform Resource Identifier (URI) as a string, following certain rules, that uniquely identifies a resource of some kind. A Uniform Resource Locator (URL) is just a special kind of URI that includes a location (such as the server name in an HTTP URL). An absolute URI is a URI that starts with the name of a so called scheme, such as http or https, followed by a colon (:) and the rest of the resource identifier. An example of an absolute URI for a resource accessed through the HTTP protocol is:

http://localhost:8080/ora/ch12/login.jsp

Here, http is the scheme, localhost:8080 is the location (a server name and a port number), and /ora/ch12/login.jsp is the path.

The URIs used in the HTML elements generated by a JSP page are interpreted by the browser. ...

Get Java Server Pages now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.