• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Jsp useBean and a bean id with a dot in the name?

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I would like to save an ArrayList object in the request scope, and then use this list in a jsp page. However I want these two things to work to:

1. I want the name of the list to contain dots, like "com.mycompany.whatever.specialarray".

2. If the arraylist does not exist in the request, then the page should *not* fail (as is the case with the struts tag <bean:define>), instead it should create an empty ArrayList.

The second issue made me try <jsp:useBean>, however that one complains when I use the id="com.mycompany.whatever.specialarray". How can I solve this? What I would like is a combination of the struts <bean:define> tag and the <jsp:useBean> tag. For example:

<someTag id="nameToUseHere" name="com.mycompany.whatever.specialarray" class=java.util.ArrayList"/>

Does such a tag exist in struts (version 1) or regular J2EE?

Regards
/Jimi
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jimi Svedenholm:
...
Does such a tag exist in struts (version 1) or regular J2EE?



I'm thinking this thread will do better in our Struts forum.
Moving.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



The present element can be used to test for beans and whether they exist or not. If a bean exists in the scope that is specified, then the code will be included in the response.
 
Jimi Svedenholm
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Clark:



The present element can be used to test for beans and whether they exist or not. If a bean exists in the scope that is specified, then the code will be included in the response.



Ok, thanks! This works. I now use this code:



But it would have been nice if I could have just skipped that <logic:present> tag and make the <bean:define> tag either create an empty ArrayList, or just let it be null.

/Jimi
[ April 29, 2008: Message edited by: Jimi Svedenholm ]
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome.

But it would have been nice if I could have just skipped that <logic_present> tag and make the <bean_define> tag either create an empty ArrayList, or just let it be null.



Struts is an open-source framework and the code for the define element is available. You still have the option of creating your own custom JSP element that functions the way you want it to.

<jimi_define id="... />
[ April 29, 2008: Message edited by: James Clark ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic