• Post Reply Bookmark Topic Watch Topic
  • New Topic

Accessing EJBs

 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to code and implement JSP client to access EJBs? Thanks in advance.
 
Marcos Maia
Ranch Hand
Posts: 977
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
here goes an WebLogic example:
<code>
< %@ page import="<br /> javax.naming.*,<br /> javax.ejb.*,<br /> java.rmi.RemoteException,<br /> java.rmi.Remote,<br /> java.util.*,<br /> examples.ejb.basic.beanManaged.* <br /> "%>
< %!<br /> String pagetitle = "JSP example using EJBean-managed persistence";<br /> String url = "t3://localhost:7001";<br /> String accountId = "10020";<br /> // Declaring a Java class<br /> public Context getInitialContext() throws Exception {<br /> Properties p = new Properties();<br /> p.put(Context.INITIAL_CONTEXT_FACTORY,<br /> "weblogic.jndi.WLInitialContextFactory");<br /> p.put(Context.PROVIDER_URL, url);<br /> return new InitialContext(p);<br /> }<br /> %>
< %<br /> Context ctx = getInitialContext();<br /> AccountHome home = (AccountHome) ctx.lookup("beanManaged.AccountHome");<br /> %>
</code>
but you should notice that usually it�s not a good idea to access ejb�s from jsp, normally you should use a Servlet Front Conttroller and a session fa�ade EJB on the ejb layer.
Take a look at: http://java.sun.com/blueprints/patterns/index.html
and also www.theserverside.com
regards.
Hi I�m not able to post code inside tags code coul�s someone tell me how to disable html and or UBB
[This message has been edited by Marcos Maia (edited December 10, 2001).]
[This message has been edited by Marcos Maia (edited December 10, 2001).]
[This message has been edited by Thomas Paul (edited December 10, 2001).]
[This message has been edited by Marcos Maia (edited December 10, 2001).]
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I fixed your code example. You need to put a space after the < and before the %.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!