[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Struts bean:write tag

Posted on 2004-10-20
7
Medium Priority
?
340 Views
Last Modified: 2013-12-29
I have this tag: <bean:write name="result"/> in one of my JSPs that is being accessed from 2 or more Action objects. One of those Action objects sets the message like so:

String message = "Successful";
request.setAttribute("result", message);

but the other Action objects dont set that bean (ie I don't need any message if it's coming from them), so when the JSP is being called from any of those Action objects, I get a JSP exception that "result" has never been set.

Is there any way around this problem other than setting a blank "result" message in every other Action that forwards to that JSP? What is the proper way of doing this? I don't want to use scripting in my JSP to check if "result" is null.

Thanks.
0
Comment
Question by:Flavaflav
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 8

Expert Comment

by:kiranhk
ID: 12363111
you can initialize ur bean variable to a default value so that in case it is not set by any action class it should display the default value
0
 
LVL 8

Expert Comment

by:kiranhk
ID: 12363132
sorry abt the above quote

you can wrap ur bean write tag with the <logic:present> so that it will check out whether it is present and then display it if is there.
0
 

Author Comment

by:Flavaflav
ID: 12363903
I tried doing this:

<logic:present><bean:write name="result"></logic:present>

but I get the following runtime exception: "No selector attribute (cookie/header/name/parameter) was specified".
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 8

Expert Comment

by:kiranhk
ID: 12364039
try this out

<logic:present name="result">
<bean:write name="result"></
</logic:present>


also go thro this

http://struts.apache.org/api/org/apache/struts/taglib/logic/package-summary.html#package_description
0
 

Author Comment

by:Flavaflav
ID: 12364370
Great thanks that worked. While we're on this subject I have another question: Using the bean:write tag, how can I get the property of a property of a bean? For example, I have:

<bean:write name="target" property="dataField">

where dataField is a DataField object belonging to the Target object, but I need to display a certain field from that DataField obj (eg. "description"). Is there a way to do this just using Struts tags, and w/out overriding toString() in DataField to return the description property?
0
 
LVL 8

Accepted Solution

by:
kiranhk earned 400 total points
ID: 12364752
<bean:write name="target" property="dataField.urpropertyname">
0
 

Author Comment

by:Flavaflav
ID: 12364930
Simple enough :>. Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

649 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