> -----Original Message-----
> From: A mailing list about Java Server Pages specification
> and reference
>
> Was just wondering if there was a way to call a constructor
> other than the
> default one using <jsp:usebean...>
>
> For example,
>
> // Default constructor
> MyBean() {
>   testVal = 0;
> }
>
> // Something different
> MyBean(int i) {
>   testVal = i;
> }
>
> I understand I can do something like this:
> <%
>   MyBean m = new MyBean(10);
> %>
>
> but is it possible to call the constructor and pass it an
> argument (the int
> i) while using the <jsp:usebean...>tags instead of using a
> get and set with
> the default constructor.  This is a poor example because
> setTestVal(int i)
> could be used easily, but for what I am working on, it would
> be much easier
> to pass arguments to the constructor and also utilize the
> <jsp:usebean....>
> tags so that our XML guys can work with it without too much
> instruction.

It would appear not. However you can put tags/code within a <jsp:useBean>
... </jsp:useBean> tag so you could call a method which actually does the
initialisation of the bean there.
There are also XML friendly versions of the <% ... %> scriplet tags -
<jsp:scriptlet> ... </jsp:scriptlet> see the JSP spec. document.

HTH,

Steve S

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to