Java Reference
In-Depth Information
<%= request.getParameter("fullName") %>,
you indicated you are familiar with the following
programming languages:</p>
<ul>
<%
String[] selectedLanguages =
request.getParameterValues("progLang");
if (selectedLanguages != null) {
for (int i = 0; i < selectedLanguages.length;
i++) {
%>
<li>
<%= selectedLanguages[i] %>
</li>
<%}
}
%>
</ul>
</body>
</html>
As we can see, this page is composed of both static HTML elements and JSP
expressions and scriptlets.
JSP expressions are enclosed in <%= and %> delimiters. Inside these delimiters we
can place any valid Java expression returning a value. The value is automatically
converted to a String and displayed on the page. To simplify expressions, JSPs
contain a number of implicit objects. One of these implicit objects is request . This
object contains the HTTP request that was generated when navigating to the page.
The first JSP expression on our output page uses the implicit request object. It is
used to retrieve the value of the request parameter named fullName . Notice that
the String we passed to this method matches the name of the text input field used
to collect the user's full name in the previous page. When that page is submitted, a
request parameter is automatically generated with this name and the user entered
input as its value. Invoking this method allows us to retrieve the data that the
user entered.
 
Search WWH ::




Custom Search