Java Tutorial/JSP/Include

Материал из Java эксперт
Версия от 17:44, 31 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Include File

index.jsp



<%--
  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  
  This software is provided without warranty
  either expressed or implied.
--%>
<%@ page session="false" %>
<h3>Flavors</h3>
Our most popular flavors are:
<%@ include file="flavor_list.html" %>
Try them all!





Include Page and Pass Parameter Through Request Object

index.jsp



<%--
  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  
  This software is provided without warranty
  either expressed or implied.
--%>
<%
   // Diameter of the earth in kilometers
   int distance = 12756;
%>
<%@ page session="false" %>
<h4>Diameter of the Earth in SI (Metric) Units</h4>
<jsp:include page="ShowDiameter.jsp" flush="true">
   <jsp:param name="dist" value="<%= distance %>" />
   <jsp:param name="units" value="SI" />
</jsp:include>
<h4>Diameter of the Earth in U.S. Customary Units</h4>
<jsp:include page="ShowDiameter.jsp" flush="true">
   <jsp:param name="dist" value="<%= distance %>" />
   <jsp:param name="units" value="US" />
</jsp:include>





Include Page by Path

<%--
  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  
  This software is provided without warranty
  either expressed or implied.
--%>
<%@ page session="false" %>
<h3>Flavors</h3>
Our most popular flavors are:
<jsp:include page="/" flush="true"/>
Try them all!