This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi there bit of a problem - i havent used JSP too much before this week - and i am trying to have one as a client to my session bean....except i dont really know how to go about it can anyone give me some good tips on starting this, or point me to a good tutorial website? I know how to do the server lookup to locate the home interface of the session but am unsure about setting up initialcontexts etc - would i be better having a bean to do this and then just start on integrating with the session beans? This has to be done for tomorrow (3pm GMT) so finding out how to do it quickly is of the essence. many thanx for any help noreen
OK, there are several ways to do this. There is the quick way, and there is the (architecturally) correct way. Being as how you have very little time to do this I suggest the quick way There is not difference in accessing your EJB from a JSP page, than accessing it from a standalone application (which I assume you have done). Here are (broadly) the steps: 1) Create you initial context <% Context context = new InitialContext(); 2) Lookup your bean Object obj= context.lookup("JNDI NAME"); BeanHome home=(BeanHome)PortableRemoteObject.narrow(obj,BeanHome.class); 3) Create your bean Bean bean = home.create(); 4) Use your bean bean.aMethod(); %> 5) Remember to catch the relevant exceptions (NamingException, CreateException, RemoteException etc) And that should be that. To do it in a better way, check out the J2EEPatterns for alternative methods. Hope this helps Rgds Sam
<a href="http://www.samjdalton.com" target="_blank" rel="nofollow">Sam Dalton</a>,<br />Co-author of [http://www.amazon.com/exec/obidos/tg/detail/-/1590592255/qid=1068633302//ref=sr_8_xs_ap_i0_xgl14/104-4904002-9274339?v=glance&s=books&n=507846]Professional JSP 2.0[/URL] (October 2003)<br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/1861007701/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional SCWCD Certification</a><br />Co-author of <a href="http://www.amazon.com/exec/obidos/ASIN/186100561X/ref=ase_electricporkchop" target="_blank" rel="nofollow">Professional Java Servlets 2.3</a>
Joined: Apr 30, 2002
yes, this looks very much as i thought it would... however our bean is deployed onto the IBM Websphere Server adn we are using the Webspher commerce suite. and it seems the jar must be placed into a specific directory -- but i would also assume it needs to be added to a classpath (or some such) that will let the server know to load it....? any ideas?