CHAPTER 3: Best Practices in Java EE Web Development 145
If you specify a context-relative or page-relative URL for the value attribute,
the context path of the web application to the URL; for example, if the context path of the web
application is /bookWeb/books, the
inurl:/bookWeb/books/book.jsp.
The
The
URL. The
Here’s the syntax without body content:
<c:redirect url="value" [context="context"]/>
Here’s the syntax with body content to specify query string parameters:
<c:redirect url="value" [context="context"]>
The
The attributes of
Table 3-23.
Name Type Description
url String The URL of the resource to redirect to
context String The name of the context when redirecting to a relative URL resource that belongs to
a foreign context
The URL, relative or absolute, follows the same URL rewriting rules as
illustrates redirecting to an external resource, which is an absolute URL.
Listing 3-55. Using
You can redirect to a resource in a foreign context using the context attribute. The URL specified
must start with a / as a context-relative URL, and as defined, the context name must also start with
a /. Listing 3-56 illustrates redirecting to a foreign resource in a foreign context.
Listing 3-56. redirecting to a foreign resource in a foreign context.
In this chapter, we have looked at the nuts and bolts of the Java EE machine in the web tier: the web
components (servlets and JSP), the feature-rich Expression Language, and the ready-to-use custom
actions (JSTL). Now we’ll talk about best-practice solutions using patterns.