This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes Using bean:define Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using bean:define" Watch "Using bean:define" New topic
Author

Using bean:define

Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Hi Guys. In a jsp page, I would like to escape html tags in a String object and found out that using struts bean will automate it. My problem is, how can I define an object from a session in jsp page and call its properties using <bean:write>

I can define its properties one by one like this:



And then

to print it out, but is there other way to Automate it? Without defining the properties one by one.

Thank you in advance
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
Try this .
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
what's the "formName" is it the attribute name of the session object? Similar to



Thank you in advance!
Ranjit Gopinathan
Ranch Hand

Joined: Jul 03, 2007
Posts: 46
formName is the name defined in struts-config for the ActionForm associated with the Action.
eg:
<form-bean name="loginActionForm"type="com.form.LoginActionForm" />
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
Hi Ranjit.

There's no associated form in struts-config since the action is just to display the page. All objects are stored in session.

Thanks!
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Jazzy Sanchez:
All objects are stored in session.

In that case, there's no need for a bean:define tag at all. Just reference the profile bean directly. Example:

The scope="session" is optional, as Struts will search for a bean named profile in all scopes if it isn't specified.
[ August 06, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Jazzy Sanchez
Ranch Hand

Joined: Apr 02, 2006
Posts: 35
It worked! Thanks Merrill
Kishore Sahu
Ranch Hand

Joined: Mar 10, 2009
Posts: 31
how to use <bean:define> with <jsp:useBean> ???


Kishore
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

DontWakeTheZombies
Rather create a separate thread.

And <bean:define>, <jsp:useBean> worked as same with little difference.
Why do you want to mix up this tags, either use <bean:define> OR <jsp:useBean> .


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using bean:define