• 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

more complex bean examples

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using beans successfully to store data as it passes from servlet to JSP page. Now I am hoping to send an array, of unknown size, through the bean. (The first version will be a list of products that will end up being in a table).

What is the correct way to do this?

I could do something like

<jsp:getProperty name="productTable" property="name1" /> <jsp:getProperty name="productTable" property="name2" />
<jsp:getProperty name="productTable" property="name3" />
<jsp:getProperty name="productTable" property="name4" />

But this seems absurd. Is there any way to support arrays in beans?

Looking at these links it is not clear:

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm14.html

http://java.sun.com/products/jsp/tags/11/syntaxref11.fm10.html
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Using JSTL with EL will do,

For Example,

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

<c:forEach var='item' begin='1' end='10'>
<c:out value='${item}'/>
</c:forEach>

And here is the reference URL for JSTL


hth,
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When using JSP 2.0, why would you be looking at a syntax reference for JSP 1.1?

Try: http://java.sun.com/products/jsp/syntax/2.0/syntaxref20.html

And, as Prabhu pointed out, the EL is now the best way to reference scoped variables.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic