Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
A.10 JSP Scripting Elements
533
Encoding URLs
In case servlet is using URL rewriting to implement session tracking, you
should give the system a chance to encode the URLs.
Regular URLs
String originalURL = someRelativeOrAbsoluteURL;
String encodedURL = response.encodeURL(originalURL);
out.println("...");
Redirect URLs
String originalURL = someURL; // Relative URL OK in 2.2
String encodedURL = response.encodeRedirectURL(originalURL);
response.sendRedirect(encodedURL);
A.10 JSP Scripting Elements
Types of Scripting Elements
Expressions: <%= expression %>
Evaluated and inserted into servlet's output. You can also use
expression
Scriptlets: <% code %>
Inserted into servlet s
_jspService
method (called by
service
). You
can also use
code
Declarations: <%! code %>
Inserted into body of servlet class, outside of any existing methods. You
can also use
code
Template Text
Use
<\%
to get
<%
in output.
<% JSP Comment %>
All other non JSP specific text passed through to output page.
Predefined Variables
Implicit objects automatically available in expressions and scriptlets (not dec
larations).
request: the
HttpServletRequest
associated with request.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.
footer
Our partners:
PHP: Hypertext Preprocessor Best Web Hosting
Java Web Hosting
Jsp Web Hosting
Cheapest Web Hosting
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved