JSP Scripting Element
 
JSP Expressions
 
A JSP expression is used to insert Java values directly into the output.
 
It has the following form:
<%= Java Expression %>
 
The Java expression is evaluated, converted to a string, and inserted in the page. This evaluation is performed at run-time (when the page is requested), and thus has full access to information about the request.
 
For example, the following shows the date/time that the page was requested:
Current time: <%= new java.util.Date() %>
To simplify these expressions, there are a number of predefined variables that we can use.
 
These implicit objects are discussed in more detail later, but for the purpose of expressions, the most important ones are:
 
. request, the HttpServletRequest;
. response, the HttpServletResponse;
. session, the HttpSession associated with the request (if any); and
. out, the PrintWriter (a buffered version of type JspWriter) used to send output to the client.
 
example:
hostname: <%= request.getRemoteHost() %>
 
Finally, note that XML authors can use an alternative syntax for JSP expressions:
 <jsp:expression>
     Java Expression
</jsp:expression>
Remember that XML elements, unlike HTML ones, are case sensitive. So be sure to use lowercase.