Entering content frame

Procedure documentation Accessing J2EE Applications from Portal Applications Locate the document in its SAP Library structure

Procedure

Portal applications can access J2EE applications such as EJBs and servlets. To do this:

...

       1.      Specify the reference

The reference is defined in portalapp.xml either in PrivateSharingReference or PublicSharingReference using the SAP J2EE application prefix "SAPJ2EE::"

Example 

<property name="PrivateSharingReference" value="SAPJ2EE::sap.com/Hello"/>

       2.      Access the application

The application is accessed via JNDI. The following is an example of a portal component accessing an EJB

Example

public void doContent(

   IPortalComponentRequest request,

   IPortalComponentResponse response) {

   String key = "Hello/Stateless/HelloStatelessBean";

 

   try {

      Context context = new InitialContext();

 

      Object obj = context.lookup(key);

      HelloHome home =

         (HelloHome) P4ObjectBroker.init().narrow(obj, HelloHome.class);

      Hello hello = home.create();

      response.write("Bean message: " + hello.getMessage());

 

Leaving content frame