>Yes, You can look up from Jsp, here is the sample code..
indeed, we use homemade 'web-beans' for this. These are 1-on-1 with the
session beans. Their purpose is to lookup the sessionbean and call its
functions.
Especially useful when developing the presentation-layer seperate from the
EJB's, you can return some testdata in the begin-fase. Later, when the
session-bean is finished/tested, you just 'connect' the webbean to the
sessionbean.
sample:
public class RequestCardServiceWeb extends AbstractWebBean
implements CardholderStatus {
private static final String BEAN_NAME = "ejb/RequestCardService";
private RequestCardService requestCard = null;
public RequestCardServiceWeb() throws RemoteException, CreateException,
NamingException {
connectToEJB();
}
private void connectToEJB() throws RemoteException, CreateException,
NamingException
{
RequestCardServiceHome home = (RequestCardServiceHome)JNDIUtil.lookup(
BEAN_NAME, RequestCardServiceHome.class);
requestCard = (RequestCardService)home.create();
}
}
// functions, 1-on-1 with the sessionbean
public int activateCard(long cardNo, String eMailAddress)
throws ActivateCardTimeoutException, FinderException, RemoteException,
UnableToActivateCardException
{
//*** test data
// return 1;
//
return requestCard.activateCard(cardNo, eMailAddress);
}
// and more functions
}
the JNDIUtil class has a function like:
public static Object lookup(String name, Class cls)
throws NamingException
{
InitialContext ctx = new InitialContext();
Object objref = ctx.lookup(name);
return PortableRemoteObject.narrow(objref, cls);
}
and, finally, in the JSP we do something like:
<%
RequestCardServiceWeb myRCS = new RequestCardServiceWeb();
int something = myRCS.activateCard(300, [EMAIL PROTECTED]);
%>
<body><form>
<input type=text value="<%=something%>">
</form></body>
Hope this helps.
greetz
Jasper Fontaine
MagicMinds BV
Media Factory
Prins Hendrikkade 100
1011 AH Amsterdam
tel. +31(0)20 30 12 248
fax. +31(0)20 30 12 202
mob. +31(0)62 18 92 725
E-mail: [EMAIL PROTECTED]
Internet: http://www.magicminds.com
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".