Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / JavaBeans / October 2006

Tip: Looking for answers? Try searching our database.

JSP: Passing more than one param into method

Thread view: 
Dave - 04 Oct 2006 20:25 GMT
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.
Manish Pandit - 04 Oct 2006 20:43 GMT
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
Dave - 04 Oct 2006 21:46 GMT
> 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)
%>
Manish Pandit - 04 Oct 2006 22:03 GMT
> <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
Dave - 04 Oct 2006 22:11 GMT
>> <jsp:useBean class="TestName" id="objx" scope="page" >
>>
[quoted text clipped - 6 lines]
> 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?
Manish Pandit - 04 Oct 2006 23:08 GMT
> 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
Dave - 05 Oct 2006 00:53 GMT
>> 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?
[quoted text clipped - 7 lines]
> opinion, the JSP should not be dealing with functionality - all such
> cases belong at the controller.

Thanks.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.