You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wes Gamble <we...@att.net> on 2008/05/19 18:25:26 UTC

How to pass OGNL expressions to JSP includes

All,

It's been a while since I've done any Struts (JSP for that matter) development, and I'm trying to get started with Struts 2.

Here's a very simple template that pulls in an include that provides the <head>...</head> content for the page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib prefix="s" uri="/struts-tags" %>

<jsp:include page="/include/head.jsp" flush="true">
  <jsp:param name="title" value="<s:property value="pageTitle"/>" />
  <jsp:param name="companyName" value="<s:property value="companyName"/>" />
</jsp:include>

<body>
</body>
</html>

I have an action that sets the values of pageTitle and companyName and I've verified that they have values.

My problem is I don't know how to correctly pass the pageTitle and companyName values set in my action (and retrievable only through OGNL, AFAIK) to the include via the standard <jsp:param> tag.  What is above doesn't work because of the double quotes.  So, here are my questions...

1) Is there a way to quote the contents of the <s:property> tag so that I can pass it successfully to the include?
2) Do I have to put the value of <s:property value="pageTitle"> (for example) into a local JSP variable just to pass it to the include?

What am I doing wrong?

Thanks,
Wes

Re: How to pass OGNL expressions to JSP includes

Posted by Randy Burgess <RB...@nuvox.com>.
To the best of my knowledge S2 uses OGNL extensively so not using it is
probably not an option. Anyone please feel free to correct me if I¹m wrong
about this. I have never used commons-el personally so I couldn¹t tell you,
sometimes the commons stuff like that extends and enhances some framework or
API, you would have to check the docs to be sure.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications




From: Wes Gamble <we...@att.net>
Reply-To: Struts Users Mailing List <us...@struts.apache.org>
Date: Mon, 19 May 2008 16:48:31 +0000
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: How to pass OGNL expressions to JSP includes

 I'm reading that OGNL is not only very slow, but also that development on
it has basically halted.

How can I ensure that I'm not using OGNL in my view?

Is the Apache commons-el different than the EL that comes w/the standard
J2EE stack?  If so, how can I use that?  Should I?

Wes
 
>  -------------- Original message from Randy Burgess <RB...@nuvox.com>:
> -------------- 
> 
> 
>> > Yes, outside of Struts tags. No that is JSP EL (Expression Language), which
>> > is different from OGNL, however you can get values from the OGNL stack
>> using 
>> > EL like in my example. There are at least a couple of links in the
>> > documentation to OGNL. I would check that first, as to EL there are tons of
>> > links on the Œnet, just Google it.
>> > 
>> > Regards, 
>> > Randy Burgess 
>> > Sr. Web Applications Developer
>> > Nuvox Communications
>> > 
>> > 
>> > 
>> > 
>> > From: Wes Gamble
>> > Reply-To: Struts Users Mailing List
>> > Date: Mon, 19 May 2008 16:38:51 +0000
>> > To: Struts Users Mailing List
>> > Subject: Re: How to pass OGNL expressions to JSP includes
>> > 
>> >  
>> > Randy, 
>> > 
>> > Thanks!  So, in general, is this an alternative way to reference these
>> > properties?  Where can I find out more about the ${...} syntax?
>> > 
>> > You said "EL" in your reply.  So, is this standard JSP EL or is it OGNL?
>> > Are they different, or is "EL" in Struts actually OGNL?
>> > 
>> > Thanks, 
>> > Wes 
>>> > >  -------------- Original message from Randy Burgess :
>>> > > --------------
>>> > > 
>>> > > 
>>>>> > >> > You can use EL outside of Struts tags.
>>>>> > >> > 
>>>>> > >> > Try   .
>>>>> > >> > 
>>>>> > >> > Properties in an action will be at the top of the stack.
>>>>> > >> > 
>>>>> > >> > Regards,
>>>>> > >> > Randy Burgess
>>>>> > >> > Sr. Web Applications Developer
>>>>> > >> > Nuvox Communications
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > From: Wes Gamble
>>>>> > >> > Reply-To: Struts Users Mailing List
>>>>> > >> > Date: Mon, 19 May 2008 16:25:26 +0000
>>>>> > >> > To: 
>>>>> > >> > Subject: How to pass OGNL expressions to JSP includes
>>>>> > >> > 
>>>>> > >> > All, 
>>>>> > >> > 
>>>>> > >> > It's been a while since I've done any Struts (JSP for that matter)
>>>>> > >> > development, and I'm trying to get started with Struts 2.
>>>>> > >> > 
>>>>> > >> > Here's a very simple template that pulls in an include that
>>>>> provides the 
>>>>> > >> > ...content for the page.
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>>>>> > >> > 
>>>>> > >> > <%@ taglib prefix="s" uri="/struts-tags" %>
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> >   " />
>>>>> > >> >   " />
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > I have an action that sets the values of pageTitle and companyName
>>>>> and I've 
>>>>> > >> > verified that they have values.
>>>>> > >> > 
>>>>> > >> > My problem is I don't know how to co rrectly pass the pageTitle and
>>>>> > >> > companyName values set in my action (and retrievable only through
OGNL, 
>>>>> > >> > AFAIK) to the include via the standard  tag.  What is above
>>>>> > >> > doesn't work because of the double quotes.  So, here are my
>>>>> questions... 
>>>>> > >> > 
>>>>> > >> > 1) Is there a way to quote the contents of the  tag so that I
>>>>> > >> > can pass it successfully to the include?
>>>>> > >> > 2) Do I have to put the value of  (for
>>>>> > >> > example) into a local JSP variable just to pass it to the include?
>>>>> > >> > 
>>>>> > >> > What am I doing wrong?
>>>>> > >> > 
>>>>> > >> > Thanks,
>>>>> > >> > Wes 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > 
>>>>> > >> > This email and any attachments ("Message") may contain legally
>>>>> privileged 
>>>> > >> and/or 
>>>>> > >> > confidential information.  If you are not the addressee, or if this
>>>>> Message 
>>>> > >> has 
>>>>> > >> > been addressed to you in error, you are not authorized to read,
>>>>> copy, or 
>>>>> > >> > distribute it, and we ask that you please delete it (including all
>>>>> copies) 
>>>> > >> and 
>>>>> > >> > notify the sender by return email.  Delivery of this Message to any
>>>>> person 
>>>> > >> other 
>>>>> > >> > than the intended recipient(s) shall not be deemed a waiver of
>>>> > >> confidentiality
>>>>> > >> > and/or a privilege.
>>> > >  
>> > 
>> > 
>> > 
>> > This email and any attachments ("Message") may contain legally privileged
>> and/or 
>> > confidential information.  If you are not the addressee, or if this Message
>> has 
>> > been addressed to you in error, you are not authorized to read, copy, or
>> > distribute it, and we ask that you please delete it (including all copies)
>> and 
>> > notify the sender by return email.  Delivery of this Message to any person
>> other 
>> > than the intended recipient(s) shall not be deemed a waiver of
>> confidentiality 
>> > and/or a privilege.
>  



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

Re: How to pass OGNL expressions to JSP includes

Posted by Wes Gamble <we...@att.net>.
 I'm reading that OGNL is not only very slow, but also that development on it has basically halted.

How can I ensure that I'm not using OGNL in my view?

Is the Apache commons-el different than the EL that comes w/the standard J2EE stack?  If so, how can I use that?  Should I?

Wes

  -------------- Original message from Randy Burgess <RB...@nuvox.com>: --------------


> Yes, outside of Struts tags. No that is JSP EL (Expression Language), which
> is different from OGNL, however you can get values from the OGNL stack using
> EL like in my example. There are at least a couple of links in the
> documentation to OGNL. I would check that first, as to EL there are tons of
> links on the �net, just Google it.
> 
> Regards,
> Randy Burgess
> Sr. Web Applications Developer
> Nuvox Communications
> 
> 
> 
> 
> From: Wes Gamble 
> Reply-To: Struts Users Mailing List 
> Date: Mon, 19 May 2008 16:38:51 +0000
> To: Struts Users Mailing List 
> Subject: Re: How to pass OGNL expressions to JSP includes
> 
>  
> Randy,
> 
> Thanks!  So, in general, is this an alternative way to reference these
> properties?  Where can I find out more about the ${...} syntax?
> 
> You said "EL" in your reply.  So, is this standard JSP EL or is it OGNL?
> Are they different, or is "EL" in Struts actually OGNL?
> 
> Thanks,
> Wes
> >  -------------- Original message from Randy Burgess :
> > -------------- 
> > 
> > 
> >> > You can use EL outside of Struts tags.
> >> > 
> >> > Try   . 
> >> > 
> >> > Properties in an action will be at the top of the stack.
> >> > 
> >> > Regards, 
> >> > Randy Burgess 
> >> > Sr. Web Applications Developer
> >> > Nuvox Communications
> >> > 
> >> > 
> >> > 
> >> > 
> >> > From: Wes Gamble
> >> > Reply-To: Struts Users Mailing List
> >> > Date: Mon, 19 May 2008 16:25:26 +0000
> >> > To: 
> >> > Subject: How to pass OGNL expressions to JSP includes
> >> > 
> >> > All, 
> >> > 
> >> > It's been a while since I've done any Struts (JSP for that matter)
> >> > development, and I'm trying to get started with Struts 2.
> >> > 
> >> > Here's a very simple template that pulls in an include that provides the
> >> > ...content for the page.
> >> > 
> >> > 
> >> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> >> > 
> >> > <%@ taglib prefix="s" uri="/struts-tags" %>
> >> > 
> >> > 
> >> >   " /> 
> >> >   " /> 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > I have an action that sets the values of pageTitle and companyName and I've
> >> > verified that they have values.
> >> > 
> >> > My problem is I don't know how to co rrectly pass the pageTitle and
> >> > companyName values set in my action (and retrievable only through OGNL,
> >> > AFAIK) to the include via the standard  tag.  What is above
> >> > doesn't work because of the double quotes.  So, here are my questions...
> >> > 
> >> > 1) Is there a way to quote the contents of the  tag so that I
> >> > can pass it successfully to the include?
> >> > 2) Do I have to put the value of  (for
> >> > example) into a local JSP variable just to pass it to the include?
> >> > 
> >> > What am I doing wrong?
> >> > 
> >> > Thanks, 
> >> > Wes 
> >> > 
> >> > 
> >> > 
> >> > 
> >> > This email and any attachments ("Message") may contain legally privileged
> >> and/or 
> >> > confidential information.  If you are not the addressee, or if this Message
> >> has 
> >> > been addressed to you in error, you are not authorized to read, copy, or
> >> > distribute it, and we ask that you please delete it (including all copies)
> >> and 
> >> > notify the sender by return email.  Delivery of this Message to any person
> >> other 
> >> > than the intended recipient(s) shall not be deemed a waiver of
> >> confidentiality 
> >> > and/or a privilege.
> >  
> 
> 
> 
> This email and any attachments ("Message") may contain legally privileged and/or 
> confidential information.  If you are not the addressee, or if this Message has 
> been addressed to you in error, you are not authorized to read, copy, or 
> distribute it, and we ask that you please delete it (including all copies) and 
> notify the sender by return email.  Delivery of this Message to any person other 
> than the intended recipient(s) shall not be deemed a waiver of confidentiality 
> and/or a privilege.  

Re: How to pass OGNL expressions to JSP includes

Posted by Randy Burgess <RB...@nuvox.com>.
Yes, outside of Struts tags. No that is JSP EL (Expression Language), which
is different from OGNL, however you can get values from the OGNL stack using
EL like in my example. There are at least a couple of links in the
documentation to OGNL. I would check that first, as to EL there are tons of
links on the Œnet, just Google it.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications




From: Wes Gamble <we...@att.net>
Reply-To: Struts Users Mailing List <us...@struts.apache.org>
Date: Mon, 19 May 2008 16:38:51 +0000
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: How to pass OGNL expressions to JSP includes

 
Randy,

Thanks!  So, in general, is this an alternative way to reference these
properties?  Where can I find out more about the ${...} syntax?

You said "EL" in your reply.  So, is this standard JSP EL or is it OGNL?
Are they different, or is "EL" in Struts actually OGNL?

Thanks,
Wes
>  -------------- Original message from Randy Burgess <RB...@nuvox.com>:
> -------------- 
> 
> 
>> > You can use EL outside of Struts tags.
>> > 
>> > Try   . 
>> > 
>> > Properties in an action will be at the top of the stack.
>> > 
>> > Regards, 
>> > Randy Burgess 
>> > Sr. Web Applications Developer
>> > Nuvox Communications
>> > 
>> > 
>> > 
>> > 
>> > From: Wes Gamble
>> > Reply-To: Struts Users Mailing List
>> > Date: Mon, 19 May 2008 16:25:26 +0000
>> > To: 
>> > Subject: How to pass OGNL expressions to JSP includes
>> > 
>> > All, 
>> > 
>> > It's been a while since I've done any Struts (JSP for that matter)
>> > development, and I'm trying to get started with Struts 2.
>> > 
>> > Here's a very simple template that pulls in an include that provides the
>> > ...content for the page.
>> > 
>> > 
>> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>> > 
>> > <%@ taglib prefix="s" uri="/struts-tags" %>
>> > 
>> > 
>> >   " /> 
>> >   " /> 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > I have an action that sets the values of pageTitle and companyName and I've
>> > verified that they have values.
>> > 
>> > My problem is I don't know how to co rrectly pass the pageTitle and
>> > companyName values set in my action (and retrievable only through OGNL,
>> > AFAIK) to the include via the standard  tag.  What is above
>> > doesn't work because of the double quotes.  So, here are my questions...
>> > 
>> > 1) Is there a way to quote the contents of the  tag so that I
>> > can pass it successfully to the include?
>> > 2) Do I have to put the value of  (for
>> > example) into a local JSP variable just to pass it to the include?
>> > 
>> > What am I doing wrong?
>> > 
>> > Thanks, 
>> > Wes 
>> > 
>> > 
>> > 
>> > 
>> > This email and any attachments ("Message") may contain legally privileged
>> and/or 
>> > confidential information.  If you are not the addressee, or if this Message
>> has 
>> > been addressed to you in error, you are not authorized to read, copy, or
>> > distribute it, and we ask that you please delete it (including all copies)
>> and 
>> > notify the sender by return email.  Delivery of this Message to any person
>> other 
>> > than the intended recipient(s) shall not be deemed a waiver of
>> confidentiality 
>> > and/or a privilege.
>  



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

Re: How to pass OGNL expressions to JSP includes

Posted by Wes Gamble <we...@att.net>.
 
Randy,

Thanks!  So, in general, is this an alternative way to reference these properties?  Where can I find out more about the ${...} syntax?

You said "EL" in your reply.  So, is this standard JSP EL or is it OGNL?  Are they different, or is "EL" in Struts actually OGNL?

Thanks,
Wes
 -------------- Original message from Randy Burgess <RB...@nuvox.com>: --------------


> You can use EL outside of Struts tags.
> 
> Try   .
> 
> Properties in an action will be at the top of the stack.
> 
> Regards,
> Randy Burgess
> Sr. Web Applications Developer
> Nuvox Communications
> 
> 
> 
> 
> From: Wes Gamble 
> Reply-To: Struts Users Mailing List 
> Date: Mon, 19 May 2008 16:25:26 +0000
> To: 
> Subject: How to pass OGNL expressions to JSP includes
> 
> All,
> 
> It's been a while since I've done any Struts (JSP for that matter)
> development, and I'm trying to get started with Struts 2.
> 
> Here's a very simple template that pulls in an include that provides the
> ...content for the page.
> 
> 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> 
> <%@ taglib prefix="s" uri="/struts-tags" %>
> 
> 
>   " />
>   " />
> 
> 
> 
> 
> 
> 
> I have an action that sets the values of pageTitle and companyName and I've
> verified that they have values.
> 
> My problem is I don't know how to co rrectly pass the pageTitle and
> companyName values set in my action (and retrievable only through OGNL,
> AFAIK) to the include via the standard  tag.  What is above
> doesn't work because of the double quotes.  So, here are my questions...
> 
> 1) Is there a way to quote the contents of the  tag so that I
> can pass it successfully to the include?
> 2) Do I have to put the value of  (for
> example) into a local JSP variable just to pass it to the include?
> 
> What am I doing wrong?
> 
> Thanks,
> Wes
> 
> 
> 
> 
> This email and any attachments ("Message") may contain legally privileged and/or 
> confidential information.  If you are not the addressee, or if this Message has 
> been addressed to you in error, you are not authorized to read, copy, or 
> distribute it, and we ask that you please delete it (including all copies) and 
> notify the sender by return email.  Delivery of this Message to any person other 
> than the intended recipient(s) shall not be deemed a waiver of confidentiality 
> and/or a privilege.  

Re: How to pass OGNL expressions to JSP includes

Posted by Randy Burgess <RB...@nuvox.com>.
You can use EL outside of Struts tags.

Try   <jsp:param name="title" value="${pageTitle}" />.

Properties in an action will be at the top of the stack.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications




From: Wes Gamble <we...@att.net>
Reply-To: Struts Users Mailing List <us...@struts.apache.org>
Date: Mon, 19 May 2008 16:25:26 +0000
To: <us...@struts.apache.org>
Subject: How to pass OGNL expressions to JSP includes

All,

It's been a while since I've done any Struts (JSP for that matter)
development, and I'm trying to get started with Struts 2.

Here's a very simple template that pulls in an include that provides the
<head>...</head> content for the page.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib prefix="s" uri="/struts-tags" %>

<jsp:include page="/include/head.jsp" flush="true">
  <jsp:param name="title" value="<s:property value="pageTitle"/>" />
  <jsp:param name="companyName" value="<s:property value="companyName"/>" />
</jsp:include>

<body>
</body>
</html>

I have an action that sets the values of pageTitle and companyName and I've
verified that they have values.

My problem is I don't know how to co rrectly pass the pageTitle and
companyName values set in my action (and retrievable only through OGNL,
AFAIK) to the include via the standard <jsp:param> tag.  What is above
doesn't work because of the double quotes.  So, here are my questions...

1) Is there a way to quote the contents of the <s:property> tag so that I
can pass it successfully to the include?
2) Do I have to put the value of <s:property value="pageTitle"> (for
example) into a local JSP variable just to pass it to the include?

What am I doing wrong?

Thanks,
Wes




This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

Re: How to pass OGNL expressions to JSP includes

Posted by Dave Newton <ne...@yahoo.com>.
The value stack should be available in a <jsp:include...>'ed tag, and
you should be able to reference your action's properties in any of the
supported ways.

Also note that S2 uses a request wrapper so that you may access value
stack variables via JSP EL (e.g. ${anActionProperty}). Note that the
normal scopes are searched *first*, before looking on the value stack.

Dave

--- Wes Gamble <we...@att.net> wrote:
> It's been a while since I've done any Struts (JSP for that matter)
> development, and I'm trying to get started with Struts 2.
> 
> Here's a very simple template that pulls in an include that provides
> the <head>...</head> content for the page.
> 
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <%@ taglib prefix="s" uri="/struts-tags" %>
> 
> <jsp:include page="/include/head.jsp" flush="true">
>   <jsp:param name="title" value="<s:property value="pageTitle"/>" />
>   <jsp:param name="companyName" value="<s:property
> value="companyName"/>" />
> </jsp:include>
> 
> <body>
> </body>
> </html>
> 
> I have an action that sets the values of pageTitle and companyName
> and I've verified that they have values.
> 
> My problem is I don't know how to correctly pass the pageTitle and
> companyName values set in my action (and retrievable only through
> OGNL, AFAIK) to the include via the standard <jsp:param> tag.  What
> is above doesn't work because of the double quotes.  So, here are my
> questions...
> 
> 1) Is there a way to quote the contents of the <s:property> tag so
> that I can pass it successfully to the include?
> 2) Do I have to put the value of <s:property value="pageTitle"> (for
> example) into a local JSP variable just to pass it to the include?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org