• Post Reply Bookmark Topic Watch Topic
  • New Topic

more complex bean examples  RSS feed

 
Tom Joiner
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • 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
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • 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'>
<cut value='${item}'/>
</c:forEach>

And here is the reference URL for JSTL


hth,
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!