You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jeff Born <jb...@charter.net> on 2003/02/02 20:34:40 UTC
logic-el and the request object
I have been unsuccessfully trying to figure out how to do something like
the following:
<logic-el:present name="request" parameter="contextPath"> do something
</logic-el:present>
if this possible? Am I going about it all wrong? I really want to check
for the existence of getParameter("body") and if the body tag exists do
something. After playing with it I couldn't even get the other example
to work right, and pretty much have fell back to the following code?
<% if ((String tempBody = request.getParameter("body")) == null) { %>
do something
<% } else { %>
do something else
<% } %>
How do I do this!!!?!?
Thanks in advance,
Jeff Born
Re: logic-el and the request object
Posted by Jeff Born <jb...@charter.net>.
I wasn't looking in the JSTL spec, once I looked there I found an
example I could extrapolate from. Thanks for pointing me in the right
direction David. BTW your example was exactly what I needed also, so
thanks again.
jb
-----Original Message-----
From: David M. Karr [mailto:dmkarr@earthlink.net]
Sent: Sunday, February 02, 2003 3:35 PM
To: struts-user@jakarta.apache.org
Subject: Re: logic-el and the request object
>>>>> "Jeff" == Jeff Born <jb...@charter.net> writes:
Jeff> I have been unsuccessfully trying to figure out how to do
something like
Jeff> the following:
Jeff> <logic-el:present name="request" parameter="contextPath"> do
something
Jeff> </logic-el:present>
Jeff> if this possible? Am I going about it all wrong? I really
want to check
Jeff> for the existence of getParameter("body") and if the body tag
exists do
Jeff> something. After playing with it I couldn't even get the
other example
Jeff> to work right, and pretty much have fell back to the following
code?
Jeff> <% if ((String tempBody = request.getParameter("body")) ==
null) { %>
Jeff> do something
Jeff> <% } else { %>
Jeff> do something else
Jeff> <% } %>
Jeff> How do I do this!!!?!?
If you're using "logic-el", then you might as well use the JSTL, which
is more
suited for this. Note that your sample code differs slightly from what
you
said in english, but this should be close enough for you. If you want
to
reverse the test, change "empty" to "not empty". Note that this code
hasn't
been compiled.
<c:choose>
<c:when test="${empty param.body}">
Do something.
</c:when>
<c:otherwise>
Do something else.
</c:otherwise>
</c:choose>
I suggest you read the JSTL specification.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: logic-el and the request object
Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Jeff" == Jeff Born <jb...@charter.net> writes:
Jeff> I have been unsuccessfully trying to figure out how to do something like
Jeff> the following:
Jeff> <logic-el:present name="request" parameter="contextPath"> do something
Jeff> </logic-el:present>
Jeff> if this possible? Am I going about it all wrong? I really want to check
Jeff> for the existence of getParameter("body") and if the body tag exists do
Jeff> something. After playing with it I couldn't even get the other example
Jeff> to work right, and pretty much have fell back to the following code?
Jeff> <% if ((String tempBody = request.getParameter("body")) == null) { %>
Jeff> do something
Jeff> <% } else { %>
Jeff> do something else
Jeff> <% } %>
Jeff> How do I do this!!!?!?
If you're using "logic-el", then you might as well use the JSTL, which is more
suited for this. Note that your sample code differs slightly from what you
said in english, but this should be close enough for you. If you want to
reverse the test, change "empty" to "not empty". Note that this code hasn't
been compiled.
<c:choose>
<c:when test="${empty param.body}">
Do something.
</c:when>
<c:otherwise>
Do something else.
</c:otherwise>
</c:choose>
I suggest you read the JSTL specification.
--
===================================================================
David M. Karr ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net ; SCJP; SCWCD
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org