Here is an example of a bean lookup method:
private SomeEntityHome getSomeEntityHome()throws NamingException {
Context context = new InitialContext();
SomeEntityHome home = (SomeEntityHome)PortableRemoteObject.narrow(
context.lookup("java:comp/env/ejb/SomeEntity"),
SomeEntityHome.class);
return home;
}
This one should be usable :)
Then its ready to call findermethods and so on.....For instance, to fine a
row in the database based on the pk:
try {
SomeEntityHome home = getSomeEntityHome();
SomeEntity remote = home.findByPrimaryKey(new SomeEntityPK(34));
catch (NamingException ne) {}
The JSP page can be coded just the same way as anything, only you dont have
to give any urls or providers and so on
to do it (if youre in the same vm/applicationserver) the ejb tag library i
mentioned earlier use this stuff inside the tag lib so the JSP code gets a
whole lot cleaner...
Klaus
-----Opprinnelig melding-----
Fra: Sean P. McNamara [mailto:[EMAIL PROTECTED]]
Sendt: 12. november 2000 01:15
Til: Orion-Interest
Emne: Re: Newbie Q: Can't find bean?
Thanks for your reply Robert, however I don't really feel it's fair
for you to have judged me ignorant of both Java and the J2EE in
general. I've done quite a bit of development with session beans, but
very little front-end (read JSP) development, and no EntityBean work,
as it wasn't supported by the EJB (1.0) containers we were working
with.
I've been through the JSP specification, and don't see anything in
there pertaining to how EJB are expected to be referenced. There is
section 2.13 describing the <jsp:useBean> tag, and unfortunately
thought it would perhaps provide the needed functionality to automate
the bean lookup process.
In addition to the specification, I have a copy of the
Monson-Haefel book on Enterprise JavaBeans, but there is virtually no
mention of JSP-EJB interaction. I also spent some time earlier today
browsing JSP-centric books in the local bookstore, and found little
mention (usually about 1 paragraph) regarding EJB's.
Obviously, using the same method that is used in a Servlet allows me
to do what I need to do. I was simply looking for a way to skip that step.
I've seen some code posted to the list using tags in the <ejb:>
namespace, but haven't located any documentation for that particular
taglib. Perhaps you could be so good as to provide a link?
I'm in the process of downloading the Romans book, so perhaps that
will have the details I'm looking for.
Thanks for the pointer.
Robert Krueger writes:
> At 14:25 11.11.00 , you wrote:
>
> >OK... I've gotten something working by removing my use of the
> >jsp:useBean tag, and instead grabbing the EntityBean home, and
> >creating manually, which seems to work.
>
> yes, bean != enterprise java bean. you will do yourself a BIG favour if
you
> read up on jsp, ejb and java in general as there are some fundamental
> basics missing. trial and error will not get you very far in J2EE. look
at
> the specs (they are actually rather readable) and maybe check out ed
romans
> ejb book (free download at www.theserverside.com).
--
Sean P. McNamara <[EMAIL PROTECTED]>
SOMA Technologies, Inc. <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>