Set Form Data to Bean and Output : Java Beans « JSTL « Java Tutorial

Home
Java Tutorial
1.Language
2.Data Type
3.Operators
4.Statement Control
5.Class Definition
6.Development
7.Reflection
8.Regular Expressions
9.Collections
10.Thread
11.File
12.Generics
13.I18N
14.Swing
15.Swing Event
16.2D Graphics
17.SWT
18.SWT 2D Graphics
19.Network
20.Database
21.Hibernate
22.JPA
23.JSP
24.JSTL
25.Servlet
26.Web Services SOA
27.EJB3
28.Spring
29.PDF
30.Email
31.J2ME
32.J2EE Application
33.XML
34.Design Pattern
35.Log
36.Security
37.Apache Common
38.Ant
39.JUnit
Java Tutorial » JSTL » Java Beans 
24.10.3.Set Form Data to Bean and Output

index.jsp

<html>
  <head><title>Create Person</title></head>
  <body>
    <h1>Enter your details</h1>
    <form action="listPageParameters.jsp" method="post">
      <table>
        <tr><td>First name:</td> <td><input type="text" name="firstName" /></td></tr>
        <tr><td>Last name:</td>  <td><input type="text" name="lastName"  /></td></tr>
        <tr><td>Age:</td>        <td><input type="text" name="age"       /></td></tr>
      </table>
      <input type="submit" value="Submit details" />
    </form>
  </body>
</html>

listPageParameters.jsp

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<html>
  <head><title> Display details</title></head>
  <body>
    <h1>Your details (or, the details that you entered!)</h1>
    <table>
      <tr><td>First name</td>
          <td><c:out value="${param.firstName}" /></td>
      </tr>
      <tr><td>Last name</td>
          <td><c:out value="${param.lastName}" /></td>
      </tr>
      <tr><td>Age</td>
          <td><c:out value="${param.age}" /></td>
      </tr>
      <%-- The following two values are not passed from the HTML form
           and are present to show the syntax for specifying default
           values --%>
      <tr><td>Partner's name</td>
          <td><c:out value="${param.partnerName}" default="Unknown name" /></td>
      </tr>
      <tr><td>Partner's age</td>
          <td><c:out value="${param.partnerAge}">
                Unknown age
              </c:out>
          </td>
      </tr>
    </table>
  </body>
</html>
  Download:  JSTLSetFormDataToBeanAndOutput.zip( 1,023 k)
24.10.Java Beans
24.10.1.Use Java Bean in JSTL
24.10.2.JSTL Working With More Than One Bean
24.10.3.Set Form Data to Bean and Output
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.