Skip to Main Content
Jakarta Struts Cookbook
book

Jakarta Struts Cookbook

by Bill Siggelkow
February 2005
Intermediate to advanced content levelIntermediate to advanced
528 pages
12h 53m
English
O'Reilly Media, Inc.
Content preview from Jakarta Struts Cookbook

3.17. Using Frames

Problem

You need to reference an Action or JSP page from within one frame to another.

Solution

Use the Struts html:frame tag to create frame elements with the proper URLs for your Struts application, as in Example 3-20 (frame_test.jsp).

Example 3-20. Generating a frame set with Struts

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<frameset cols="50%,*">
  <html:frame frameName="_frame1" 
                   page="/frame1.jsp" 
            marginwidth="10" 
           marginheight="10"
              scrolling="auto" 
            frameborder="1"/>
  <html:frame frameName="_frame2" 
                   page="/frame2.jsp" 
            marginwidth="10" 
           marginheight="10"
              scrolling="auto" 
            frameborder="1"/>
</frameset>

Within the individual frame's source JSP, use the target attribute on the html:link and html:form tags to refer to the other frame. The JSP in Example 3-21 (frame1.jsp) demonstrates this approach.

Example 3-21. Frame with link to other frame

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<html>
<head>
  <title>Struts Cookbook - Chapter 04: Frame Test</title>
</head>
<body bgcolor="white">
<h2>Frame 1</h2>
  <html:link href="frame2.jsp?calledBy=FRAME_1" target="_frame2">
    Call Frame2
  </html:link>
  <p>
  Message received:&nbsp;
  <c:out value="${FrameForm.map.message}"/>
</body>
</html>

Likewise, frame2.jsp shown in Example ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming Jakarta Struts

Programming Jakarta Struts

Chuck Cavaness
Beginning Spring Framework 2

Beginning Spring Framework 2

Bruce Snyder, Sing Li, Anne Horton, Thomas Van de Velde, Naveen Balani, Christian Dupuis
Java Cookbook

Java Cookbook

Ian F. Darwin
Struts 2 in Action

Struts 2 in Action

J. Scott Stanlick, Chad Michael Davis, Donald J. Brown

Publisher Resources

ISBN: 059600771XSupplemental ContentErrata Page