Java Tutorial/JSTL/Output

Материал из Java эксперт
Перейти к: навигация, поиск

Do Calculation in JSTL C:Out

<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.ru/jstl/core" %>
<html>
  <head>
    <title>JSP is Easy</title>
  </head>
  <body bgcolor="white">
    <h1>JSP is as easy as ...</h1>
    <%-- Calculate the sum of 1 + 2 + 3 dynamically --%>
    1 + 2 + 3 = <c:out value="${1 + 2 + 3}" />
  </body>
</html>





Output Default Value

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Out Default Examples</title>
  </head>
  <body>testit = 
  <c:out value="${testit}" default="Default Value" />
  </body>
</html>





Output Form Default Value

<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>





Output Value

<%@ taglib uri="http://java.sun.ru/jstl/core" prefix="c" %>
<html>
  <head>
    <title>Out Examples</title>
  </head>
  <body>
  <h3>Out Example</h3>
  10 * 3 = 
  <c:out value="${10*3}" />
  <br />
  </body>
</html>





Use JSTL C:Out

   <source lang="java">

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

 <head>
   <title>Query String Example</title>
 </head>
 <body>Your favorite color is: 
 
   <c:out value="${param.color}" />
 
 

Choose your favorite color: