• Menu
  • Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

JavaBeat

Java Tutorial Blog

  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)
  • Java
    • Java 7
    • Java 8
    • Java EE
    • Servlets
  • Spring Framework
    • Spring Tutorials
    • Spring 4 Tutorials
    • Spring Boot
  • JSF Tutorials
  • Most Popular
    • Binary Search Tree Traversal
    • Spring Batch Tutorial
    • AngularJS + Spring MVC
    • Spring Data JPA Tutorial
    • Packaging and Deploying Node.js
  • About Us
    • Join Us (JBC)

Struts BEAN Page Tag ( < bean:page >)

September 30, 2010 //  by Krishna Srinivasan//  Leave a Comment

Struts BEAN Tag Library

Struts BEAN tag library provides tags which are usefull in accessing beans and their properties as well as defining new beans (based on these accesses) that are accessible to the remainder of the page via scripting variables and page scope attributes. Convenient mechanisms to create new beans based on the value of request cookies, headers, and parameters are also provided.

Syntax to use Struts BEAN tag library

&lt;%@ taglib prefix=&quot;bean&quot; uri=&quot;http://struts.apache.org/tags-bean&quot; %&gt;

< bean:page >

< bean:page > – It is used to retrieve the value from the Page Context of this current page and make it accessible from current page. Name property of this tag must be one of the application, config, request, response, or session.

Example Code for < bean:page>

In this example we do not need the ActionForm bean.
In this example we do not need the Action class.
No need to configure struts-config.xml file

Create a simple jsp page BeanPageTag.jsp which illustrates the < bean:page> tag by id and property attributes.

&lt;%@page contentType=&quot;text/html&quot; pageEncoding=&quot;UTF-8&quot;%&gt;
&lt;%@taglib prefix=&quot;html&quot; uri=&quot;http://jakarta.apache.org/struts/tags-html&quot; %&gt;
&lt;%@taglib prefix=&quot;bean&quot; uri=&quot;http://jakarta.apache.org/struts/tags-bean&quot; %&gt;

&lt; html&gt;
    &lt; head&gt;

        &lt; title&gt; Bean Page Tag &lt;/title&gt;
    &lt; head&gt;
    &lt; body bgcolor=&quot;#DDDDDD&quot;&gt;
        &lt; h1 &gt; bean:page tag example  &lt;/h1&gt;

		   &lt; bean:page id=&quot;variable1&quot; property=&quot;request&quot;&gt;
		   &lt; bean:page id=&quot;variable2&quot; property=&quot;application&quot;&gt;
            &lt; h3&gt; Session:&lt;/h3&gt; &lt; bean:write name=&quot;variable1&quot; /&gt; &lt; br&gt;
            &lt; h3&gt; Application:&lt;/h3&gt; &lt; bean:write name=&quot;variable2&quot; /&gt;
		  &lt;/body&gt;
&lt;/html&gt;

5.Building and running the application
Output

Access page:http://localhost:8084/beanpage/BeanPageTag.jsp

also read:

  • Struts 2.0 Introduction and Validations using Annotations
  • Introduction to Struts Actions
  • What’s new in Struts 2.0?
  • Internationalization and Taglibs in Struts 1.2

Category: StrutsTag: Struts Tags

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Previous Post: « Struts BEAN Define Tag ( < bean:define >)
Next Post: BlackBerry Java Application Development »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow Us

  • Facebook
  • Pinterest

FEATURED TUTORIALS

New Features in Spring Boot 1.4

Difference Between @RequestParam and @PathVariable in Spring MVC

What is new in Java 6.0 Collections API?

The Java 6.0 Compiler API

Introductiion to Jakarta Struts

What’s new in Struts 2.0? – Struts 2.0 Framework

JavaBeat

Copyright © by JavaBeat · All rights reserved
Privacy Policy | Contact