Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > JSP: Passing more than one param into method

Reply
Thread Tools

JSP: Passing more than one param into method

 
 
Dave
Guest
Posts: n/a
 
      10-04-2006
If I have instantiated a controller class in a JSP page (using
<jsp:useBean...>), can I call methods which have more than one parameter
from within that JSP page?

The reason I ask is that AIUI, methods with more than one parameter do not
meet the JavaBean spec.


 
Reply With Quote
 
 
 
 
Manish Pandit
Guest
Posts: n/a
 
      10-04-2006
Hi,

You cannot use <jsp:setProperty> for methods that accept more than 1
param, as the value attribute only accepts 1 literal. Besides, as you
correctly pointed out - such methods do not follow the JavaBeans
standard.

-cheers,
Manish

 
Reply With Quote
 
 
 
 
Dave
Guest
Posts: n/a
 
      10-04-2006
"Manish Pandit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ps.com...
> Hi,
>
> You cannot use <jsp:setProperty> for methods that accept more than 1
> param, as the value attribute only accepts 1 literal. Besides, as you
> correctly pointed out - such methods do not follow the JavaBeans
> standard.


Could I use something like...?

<jsp:useBean class="TestName" id="objx" scope="page" >

<%
objx.testMethod(param1, param2)
%>


 
Reply With Quote
 
Manish Pandit
Guest
Posts: n/a
 
      10-04-2006
> <jsp:useBean class="TestName" id="objx" scope="page" >
>
> <%
> objx.testMethod(param1, param2)
> %>


Yes - I thought you were refering to setting properties in the original
post. The above will work assuming param1 and param2 are either
page-scoped, or are java variables you delcared somewhere in a
scriptlet.

-cheers,
Manish

 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      10-04-2006
"Manish Pandit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>> <jsp:useBean class="TestName" id="objx" scope="page" >
>>
>> <%
>> objx.testMethod(param1, param2)
>> %>

>
> Yes - I thought you were refering to setting properties in the original
> post. The above will work assuming param1 and param2 are either
> page-scoped, or are java variables you delcared somewhere in a
> scriptlet.


Thanks.

One last question - do the objects instantiated in a JSP page *need* to
adhere to the JavaBean convention or can they be any Java object at all?


 
Reply With Quote
 
Manish Pandit
Guest
Posts: n/a
 
      10-04-2006
> One last question - do the objects instantiated in a JSP page *need* to
> adhere to the JavaBean convention or can they be any Java object at all?


They can be any java object, but if you want to set/get properties
using jsp:setProperty and jsp:setProperty, they have to have the
property setters/getters per JavaBeans specification.

If you intend on using jsp:useBean to instantiate an object and later
use it in a *scriptlet*, you are free to use any object. However, in my
opinion, the JSP should not be dealing with functionality - all such
cases belong at the controller.

-cheers,
Manish

 
Reply With Quote
 
Dave
Guest
Posts: n/a
 
      10-04-2006
"Manish Pandit" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>> One last question - do the objects instantiated in a JSP page *need* to
>> adhere to the JavaBean convention or can they be any Java object at all?

>
> They can be any java object, but if you want to set/get properties
> using jsp:setProperty and jsp:setProperty, they have to have the
> property setters/getters per JavaBeans specification.
>
> If you intend on using jsp:useBean to instantiate an object and later
> use it in a *scriptlet*, you are free to use any object. However, in my
> opinion, the JSP should not be dealing with functionality - all such
> cases belong at the controller.


Thanks.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to break long method name into more than one line? Herman Python 7 03-13-2012 10:35 AM
HTML::Template->param() : You gave me an odd number of parameters to param()! Dave Perl Misc 5 04-26-2011 02:44 AM
Can i have more access to post data in a file other than mentionedin 'action' param ? pradnya Javascript 1 01-10-2008 03:23 PM
Overload by deriv class param; call w base class param ectoplasm C++ 12 07-28-2005 08:20 AM
XSLT: How to replace param name with this param's value ? Geathaa XML 2 07-30-2003 06:48 AM



Advertisments