Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EJBs and Web pages

Status
Not open for further replies.

timmbo

Programmer
Feb 22, 2001
167
US
Hi Everyone,
I am attempting to run my jsp with code from my EJB. The following error occurs.

Can't make static reference to method java.util.Vector getAccountsList() in class.

This is my jsp code:
<select name...>
<%
for(int i=0;i<StorAccountsListView.getAccountsList().size();i++) {
String accounts = (String)StorAccountsListView.getAccountsList().elementAt(i);
%>
<option><%=accounts%></option>
<%
}
%>
</select>


My EJB StorAccountsListView.java has
public Vector getAccountsList() {
return accountsList;
}

I am very new to this and ANY help would be most appreciated. Please remember I don't have the verbal jargen down yet.

Thanks for your help!
Tim
 
You'll first have to instantiate the class. Normally this works via the following:

StorAccountsListView view = new StorAccountsListView(...params...);
Vector v = view.getAccountsList();

With EJBs in JSPs it's a little harder (wow - you started with the hard stuff, didn't you?):

You'll have to get the beans in the .jsp even before the <html> tag via code pretty much like the following (copied without modification from a project I'm working on - this code works if the EJB classes have the right names :)):

<ejb:useHome id=&quot;uhome&quot; type=&quot;project.bean.UserHome&quot; location=&quot;UserHashBean&quot; />
<ejb:useBean id=&quot;user&quot; type=&quot;project.bean.UserRemote&quot; scope=&quot;session&quot;>
<ejb:createBean instance=&quot;<%=uhome.create(request.getParameter(\&quot;username\&quot;))%>&quot; />
</ejb:useBean>

You could then access the bean (actually the remote interface) via the name &quot;user&quot; (without the &quot;&quot;s). This would then give:

Vector v = user.getAccountsList();

Phew - hope I did help a little... allow thyself to be the spark that lights the fire
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top