Louis Voo wrote:
>
> Hi,
>
> I want to declare an array object in <jsp:useBean> tag, is it possible?
> for example i can declare
> <jsp:useBean id="msgbeans" scope="session" class="MessageBean" />
> but how to make the msgbeans variable become array?
<jsp:useBean> can only be used to create instances of classes that
have a no-args constructor (one of the requirements for a bean).
If you need an array, you can use a scriptlet and declare it with
Java code (as someone else replied). If you want to avoid Java code
in your pages (which I recommend), you can create another bean that
has a property that holds an array of beans:
public class MessageListBean {
MessageBean[] msgs;
public MessageListBean() {
// Maybe code to initialize the array elements
}
public MessageBean[] getMessages() {
return msgs;
}
}
<jsp:useBean id="msgbeans" scope="session" class="MessageListBean" />
Hans
--
Hans Bergsten [EMAIL PROTECTED]
Gefion Software http://www.gefionsoftware.com
Author of JavaServer Pages (O'Reilly), http://TheJSPBook.com
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://archives.java.sun.com/jsp-interest.html
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.jsp
http://www.jguru.com/faq/index.jsp
http://www.jspinsider.com