As far as I know you do have to do something like this in every page. I 
tend to use intermediate JavaBeans to do the dirty work or calling and 
executing the right methods and the JSP becomes quite clean.

It usually contains one import statement, creation of the JavaBean object 
and then executing the method that does the job or getting the initial 
context and all the other stuff. Also I try and use try catch blocks to 
ensure that the methods in the JavaBeans don't throw any exceptions at all, 
so the JSPs can look neat and clean.

Hope this helps.

Devraj

At 05:23 10/07/01 +0100, you wrote:


>         Hello All,
>
>         Whenever I need to use a stateless session bean I have to put the 
> following
>in my JSP:
>
>      javax.naming.Context mycontext = new javax.naming.InitialContext();
>      java.lang.Object library_ref = mycontext.lookup("acc_library");
>      accessprj.acc_libraryHome libraryhome = (accessprj.acc_libraryHome)
>javax.rmi.PortableRemoteObject.narrow(library_ref,accessprj.acc_libraryHome.
>class);
>      accessprj.acc_library library =libraryhome.create();
>
>I made a Class to set the properties as follows:
>
>public class ContextPropertiesFactory {
>   public Properties getInitialContextPropertiesFactory() {
>     Properties prop = new Properties();
>
>prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingC
>ontextFactory");
>     prop.setProperty(Context.PROVIDER_URL,"localhost:1099");
>     return prop;
>   }
>   public void makePropertiesDefault() {
>     System.setProperties(getInitialContextPropertiesFactory());
>   }
>}
>
>Now I call the getInitialContextPropertiesFactory() method and initialize my
>context with the Properties that are returned from the method so I can use
>JBoss.
>
>Do I have to do something like this in every JSP page I have??
>
>         Thanks in advance,
>         Carlos Ferrao
>
>
>_______________________________________________
>JBoss-user mailing list
>[EMAIL PROTECTED]
>http://lists.sourceforge.net/lists/listinfo/jboss-user


_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to