Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Mark S Petrovic
Wow.  Right on.  Using the  with additional attributes as shown
in the wiki entry below indeed solved the problem.

Thank you, and thanks to everyone else who patiently read my posts
and offered help.

Mark

On 15Nov, Rahul Akolkar wrote:
> On 11/15/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> > I know I'll look back on this learning curve with a head-slapping
> > recollection, but until then, for posterity:
> >
> > 1.  If I remove the taglib directive in the JSP, the various  tags
> > are copied directly into the html output, with the browser doing its
> > best to just ignore them.  The plaintext tag body content is actually
> > rendered, again, the result of the browser doing its best with what it
> > considers unknown markup.
> >
> > 2.  When I put the taglib directive back in, the JSP compiles and
> > subsequently does something with the  tag directives, as the tags are
> > no longer copied into the resultant html and the default 
> > always seems to execute.  Nor do I receive any exception output in the
> > browser or in the catalina.out logfile.
> >
> > Whatever is misconfigured in my app is not a completely fatal situation:
> > I just can't get at the scripting variables to do meaningful operations
> > on them.
> >
> 
> 
> Match JSTL to Servlet/JSP spec. You're using JSTL 1.1, and I suspect
> you don't have a Servlet 2.4 web.xml. Some details are here [1].
> 
> -Rahul
> 
> [1] http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Leahy, Kevin
Hi 

I had a similar problem a while back and found that using this instead
worked:

<%@ taglib uri="http://java.sun.com/jstl/core"; prefix="c" %>

I don't know why.

Might be worth a try.

-Original Message-
From: Mark S Petrovic [mailto:[EMAIL PROTECTED] 
Sent: 15 November 2005 16:34
To: Struts Users Mailing List
Subject: Re: Newbie help with Struts idiom: functional if/else tags

I know I'll look back on this learning curve with a head-slapping
recollection, but until then, for posterity:

1.  If I remove the taglib directive in the JSP, the various  tags are
copied directly into the html output, with the browser doing its best to
just ignore them.  The plaintext tag body content is actually rendered,
again, the result of the browser doing its best with what it considers
unknown markup.

2.  When I put the taglib directive back in, the JSP compiles and
subsequently does something with the  tag directives, as the tags are no
longer copied into the resultant html and the default  always
seems to execute.  Nor do I receive any exception output in the browser or
in the catalina.out logfile.

Whatever is misconfigured in my app is not a completely fatal situation:
I just can't get at the scripting variables to do meaningful operations on
them.

On 15Nov, Mark Petrovic wrote:
> On 15Nov, Dave Newton wrote:
> > Mark S Petrovic wrote:
> > 
> > >which isn't even iterating over the list items.  E.g, I get one 
> > >line of html output for the  
> > >tag, containing the string literal '${feature.premium}' in quotes - 
> > >as if expansion of ${feature.premium} is not taking place.
> > > 
> > >
> > You're using the JSP taglib directive? You have all the necessary 
> > JARs for JSTL? J2EE version your app server implements?
> 
> 1. The JSP has the following taglib directive
> 
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
> 
> 2. In my WEB-INF/lib directory I have files and checksums
> 
> 1677728891 20682 webapps/mx/WEB-INF/lib/jstl.jar
> 1935831951 393259 webapps/mx/WEB-INF/lib/standard.jar
> 
> from the TagLibs Standard 1.1.2 binary distrbution
> 
> 3. I'm using Apache Tomcat/5.5.12.
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

--
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express 
written permission of the sender. If you are not the intended recipient, please 
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender. 3166



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Rahul Akolkar
On 11/15/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> I know I'll look back on this learning curve with a head-slapping
> recollection, but until then, for posterity:
>
> 1.  If I remove the taglib directive in the JSP, the various  tags
> are copied directly into the html output, with the browser doing its
> best to just ignore them.  The plaintext tag body content is actually
> rendered, again, the result of the browser doing its best with what it
> considers unknown markup.
>
> 2.  When I put the taglib directive back in, the JSP compiles and
> subsequently does something with the  tag directives, as the tags are
> no longer copied into the resultant html and the default 
> always seems to execute.  Nor do I receive any exception output in the
> browser or in the catalina.out logfile.
>
> Whatever is misconfigured in my app is not a completely fatal situation:
> I just can't get at the scripting variables to do meaningful operations
> on them.
>


Match JSTL to Servlet/JSP spec. You're using JSTL 1.1, and I suspect
you don't have a Servlet 2.4 web.xml. Some details are here [1].

-Rahul

[1] http://wiki.apache.org/jakarta-taglibs/FrequentlyAskedQuestions

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Dave Newton

Mark S Petrovic wrote:


Whatever is misconfigured in my app is not a completely fatal situation:
I just can't get at the scripting variables to do meaningful operations
on them.
 


Can you set a String into scope:

request.setAttribute("foo", "bar");

then in a JSP do:



?

Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Mark S Petrovic
I know I'll look back on this learning curve with a head-slapping
recollection, but until then, for posterity:

1.  If I remove the taglib directive in the JSP, the various  tags
are copied directly into the html output, with the browser doing its
best to just ignore them.  The plaintext tag body content is actually
rendered, again, the result of the browser doing its best with what it
considers unknown markup.

2.  When I put the taglib directive back in, the JSP compiles and
subsequently does something with the  tag directives, as the tags are
no longer copied into the resultant html and the default 
always seems to execute.  Nor do I receive any exception output in the
browser or in the catalina.out logfile.

Whatever is misconfigured in my app is not a completely fatal situation:
I just can't get at the scripting variables to do meaningful operations
on them.

On 15Nov, Mark Petrovic wrote:
> On 15Nov, Dave Newton wrote:
> > Mark S Petrovic wrote:
> > 
> > >which isn't even iterating over the list items.  E.g, I get one line of
> > >html output for the  tag, containing
> > >the string literal '${feature.premium}' in quotes - as if expansion of
> > >${feature.premium} is not taking place.
> > > 
> > >
> > You're using the JSP taglib directive? You have all the necessary JARs 
> > for JSTL? J2EE version your app server implements?
> 
> 1. The JSP has the following taglib directive
> 
> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>
> 
> 2. In my WEB-INF/lib directory I have files and checksums 
> 
> 1677728891 20682 webapps/mx/WEB-INF/lib/jstl.jar
> 1935831951 393259 webapps/mx/WEB-INF/lib/standard.jar
> 
> from the TagLibs Standard 1.1.2 binary distrbution
> 
> 3. I'm using Apache Tomcat/5.5.12.
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Mark S Petrovic
On 15Nov, Dave Newton wrote:
> Mark S Petrovic wrote:
> 
> >which isn't even iterating over the list items.  E.g, I get one line of
> >html output for the  tag, containing
> >the string literal '${feature.premium}' in quotes - as if expansion of
> >${feature.premium} is not taking place.
> > 
> >
> You're using the JSP taglib directive? You have all the necessary JARs 
> for JSTL? J2EE version your app server implements?

1. The JSP has the following taglib directive

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %>

2. In my WEB-INF/lib directory I have files and checksums 

1677728891 20682 webapps/mx/WEB-INF/lib/jstl.jar
1935831951 393259 webapps/mx/WEB-INF/lib/standard.jar

from the TagLibs Standard 1.1.2 binary distrbution

3. I'm using Apache Tomcat/5.5.12.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Dave Newton

Mark S Petrovic wrote:


which isn't even iterating over the list items.  E.g, I get one line of
html output for the  tag, containing
the string literal '${feature.premium}' in quotes - as if expansion of
${feature.premium} is not taking place.
 

You're using the JSP taglib directive? You have all the necessary JARs 
for JSTL? J2EE version your app server implements?


Dave



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Mark S Petrovic

On 15Nov, Mark Petrovic wrote:

> > >
> > 
> > Should just be  

Sorry.  I failed to mention in my reply that I tried this, too, and it
made no difference in the html output.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-15 Thread Mark S Petrovic
Thank you for the reply.

1.  I want to say yes, Feature is a proper JavaBean, with essentials

public class Feature {
  private boolean premium;
  public void setPremium(boolean b) { premium = b; }
  public boolean isPremium(){ return premium; }
}

and no overloaded methods.

"features" is populated thusly

ArrayList features = new ArrayList();
Feature f = new Feature();
f.setPremium(true); // e.g.
features.add(f);

and finally, in the Action.execute() method of the associated Struts
action

request.setAttribute("features", features);
return (mapping.findForward(target));

where the request.setAttribute() is the share-with-JSP-view technique
used by the Struts book I'm reading.

2.  Failing to get the  to work within  in
#1 above, I also tried a different tack:  using  instead of
 to cycle through the list elements that 
formerly treated:

For the same ArrayList "features", containing instances of bean "Feature"
as above and set with the same Struts Action.execute via

request.setAttribute("features", features);

I attempt


   
  
 

   True


   False

 
  
  
 
  
   


which isn't even iterating over the list items.  E.g, I get one line of
html output for the  tag, containing
the string literal '${feature.premium}' in quotes - as if expansion of
${feature.premium} is not taking place.

I know the issues I'm raising are very elementary, but I hope they help
someone else in the process.

Mark

On 14Nov, Wendy Smoak wrote:
> On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> 
> >
> 
> Should just be  
> 
> Is 'feature' a proper JavaBean?  The types for get(is)/set methods
> match, no overloaded set methods, etc?
> 
> --
> Wendy
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Wendy Smoak
On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:

>

Should just be  

Is 'feature' a proper JavaBean?  The types for get(is)/set methods
match, no overloaded set methods, etc?

--
Wendy

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Mark S Petrovic
I'm still stumbling on some details.  

For


   
  
 

   


   

 
  
   


fwiw, "features" is put in the request scope using 

request.setAttribute("features", features);

in the Action that provides data to this JSP view.

The JSP prints false for cases where I know feature.isPremium() is true.
I suspect the 'feature' scripting variable has different meanings in the
two ways in which it is being used (logic:iterate tag and c:choose tag)

Help is appreciated, and I'm on my way to get modern books on both Struts
and JSPs.

On 14Nov, Craig McClanahan wrote:
> On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> >
> > Good day. I am new to Struts, and while I am coming up to speed, I'm
> > still struggling with what are surely common idioms.
> >
> > In a JSP, I want to output, say, a  element body conditionally based
> > on a given bean property.
> >
> > In pseudocode, I want
> >
> > if bean.property == true
> > print  X 
> > else
> > print  Y 
> >
> > I examined the Struts Logic tags, but found no if/else construct, and
> > I suspect there is a good reason for this.
> >
> > Does Struts culture encourage me to somehow move the solution into the
> > bean itself, or is there a informed, stylish way to deal with this in
> > the JSP?
> 
> 
> You can easily simulate if/else (or even if - else if - else if) chains with
> the JSTL  tag, with nested  or  tags. It's
> similar in spirit to using the "switch" statement in Java or C.
> 
> Craig
> 
> 
> Thank you.
> >
> > -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >

-- 
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Larry Meadors
I like this:


  true


Larry

On 11/14/05, Michael Jouravlev <[EMAIL PROTECTED]> wrote:
> Use either Struts  or JSTL  or bare scriptlet. In
> your particular case you can make the decision in the bean itself. Do
> not print HTML tags from Java, this produces unmaintable and
> unportable code.
>
> Michael.
>
> On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> > Good day.  I am new to Struts, and while I am coming up to speed, I'm
> > still struggling with what are surely common idioms.
> >
> > In a JSP, I want to output, say, a  element body conditionally based
> > on a given bean property.
> >
> > In pseudocode, I want
> >
> > if bean.property == true
> >print  X 
> > else
> >print  Y 
> >
> > I examined the Struts Logic tags, but found no if/else construct, and
> > I suspect there is a good reason for this.
> >
> > Does Struts culture encourage me to somehow move the solution into the
> > bean itself, or is there a informed, stylish way to deal with this in
> > the JSP?
> >
> > Thank you.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Mark S Petrovic
Thank you for the reply.

Using, for example,  seems to solve only half the problem.
Using , I can see my way clear to


   True


   True


which gives a crude if/else effect, but this is almost surely ill advised.
I think the same would apply to , as I know of no "else" construct
that goes with either.

One could also perhaps use



...


...



which looks a bit better.

Thanks.

Mark

On 14Nov, Michael Jouravlev wrote:
> Use either Struts  or JSTL  or bare scriptlet. In
> your particular case you can make the decision in the bean itself. Do
> not print HTML tags from Java, this produces unmaintable and
> unportable code.
> 
> Michael.
> 
> On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> > Good day.  I am new to Struts, and while I am coming up to speed, I'm
> > still struggling with what are surely common idioms.
> >
> > In a JSP, I want to output, say, a  element body conditionally based
> > on a given bean property.
> >
> > In pseudocode, I want
> >
> > if bean.property == true
> >print  X 
> > else
> >print  Y 
> >
> > I examined the Struts Logic tags, but found no if/else construct, and
> > I suspect there is a good reason for this.
> >
> > Does Struts culture encourage me to somehow move the solution into the
> > bean itself, or is there a informed, stylish way to deal with this in
> > the JSP?
> >
> > Thank you.
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Mark Petrovic
Pasadena, CA  USA

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Craig McClanahan
On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
>
> Good day. I am new to Struts, and while I am coming up to speed, I'm
> still struggling with what are surely common idioms.
>
> In a JSP, I want to output, say, a  element body conditionally based
> on a given bean property.
>
> In pseudocode, I want
>
> if bean.property == true
> print  X 
> else
> print  Y 
>
> I examined the Struts Logic tags, but found no if/else construct, and
> I suspect there is a good reason for this.
>
> Does Struts culture encourage me to somehow move the solution into the
> bean itself, or is there a informed, stylish way to deal with this in
> the JSP?


You can easily simulate if/else (or even if - else if - else if) chains with
the JSTL  tag, with nested  or  tags. It's
similar in spirit to using the "switch" statement in Java or C.

Craig


Thank you.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


Re: Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Michael Jouravlev
Use either Struts  or JSTL  or bare scriptlet. In
your particular case you can make the decision in the bean itself. Do
not print HTML tags from Java, this produces unmaintable and
unportable code.

Michael.

On 11/14/05, Mark S Petrovic <[EMAIL PROTECTED]> wrote:
> Good day.  I am new to Struts, and while I am coming up to speed, I'm
> still struggling with what are surely common idioms.
>
> In a JSP, I want to output, say, a  element body conditionally based
> on a given bean property.
>
> In pseudocode, I want
>
> if bean.property == true
>print  X 
> else
>print  Y 
>
> I examined the Struts Logic tags, but found no if/else construct, and
> I suspect there is a good reason for this.
>
> Does Struts culture encourage me to somehow move the solution into the
> bean itself, or is there a informed, stylish way to deal with this in
> the JSP?
>
> Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Newbie help with Struts idiom: functional if/else tags

2005-11-14 Thread Mark S Petrovic
Good day.  I am new to Struts, and while I am coming up to speed, I'm
still struggling with what are surely common idioms.

In a JSP, I want to output, say, a  element body conditionally based
on a given bean property.

In pseudocode, I want

if bean.property == true
   print  X 
else
   print  Y 

I examined the Struts Logic tags, but found no if/else construct, and
I suspect there is a good reason for this.

Does Struts culture encourage me to somehow move the solution into the
bean itself, or is there a informed, stylish way to deal with this in
the JSP?

Thank you.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]