Solved

How to Display Struts Data with Tags

Posted on 2006-10-31
3
998 Views
Last Modified: 2013-11-24
I'm not sure if I'm propertly using struts.   There's data I want to display on my JSP.  
I'm getting confused by all these tag libs:  nested, c:out,  bean:write

Seems I'm inconsistently using them all over the place, but none really quite work right.

What's the easiest most maintainable, proper way to display this data?  Note: my JSP is not dialog form.

1. From Servlet
    ABCForm myForm = new ABCForm
    form.setData("my data string");


2.  My STRUTS SETUP
    <form-bean      name="abcForm"
                           type="com.myPath.ABCForm"/>

              < ... >

    <action path="/trainMe"
               type="com.myPath.ABCAction"
               name="abcForm"
              scope="session"
            validate="false">
      <forward name="success"              path="/jsp/success.jsp"/>
    </action>
   
3.  How do I display propertly the form tags on my JSP? using JSTL...

   
0
Comment
Question by:tmonteit
3 Comments
 
LVL 14

Expert Comment

by:boonleng
ID: 17847056
For my development, I only use <tiles>, <html> and <nested> form tag. I have replaced <bean> and <logic> tag with JSTL <c> and <fmt> which is much better.
Nowaday, I don't even use <c:out> to display data unless I want the application to be compatible with J2EE 1.3, I directly use EL since Im using JSP 2.0.

To display propertly of the form using JSTL, just form bean name follow by the property name.
Example:
<c:out value="${abcForm.data}"/>

0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 17848302
I agree with boonleng completely.

The struts team recommend the usage of JSTL over the logic library anyway so it's better to replace as much as you can with JSTL.
0
 

Accepted Solution

by:
hfloresrey earned 300 total points
ID: 17885366
On the other if you are learning it is easier to add something like this on the top of your jps

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>


and then use

<bean:write name="abcForm" property="data" />
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tenRun challenge 28 88
for loop with Set 4 48
Spring Controller - inheritance in request parameter 3 48
servlet example issue 6 27
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now