As far as I understand, the java:/comp/env (ENC) stuff is unlikely to be supported if you are running separates. Since it gives each EAR it's own individual namespace it is not a normal JNDI lookup into a flat namespace. The integration code that holds JBoss/Tomcat or JBoss/Jetty together provides this functionality. Bear in mind that I know very little about Tomcat, being the Jetty integrator. For a better answer try [EMAIL PROTECTED] or the user forums on the jboss web site. Try the in-vm integration with Tomcat or Jetty - I suspect your problem will disappear. as for 'it is violate the distributed computing principle' - in my book anything that makes my app go faster is fine. Provided that there is clean separation between tiers I see nothing wrong in running them on the same box, or even in the same vm. Of course, if you want to keep your options open you need to be aware of what features work where, and it looks like you have just stumbled across your first. Hope that helps, Jules cidy long wrote: > Jules Gosnell > > I need a favor. > > I am cidy long from Australia. I have to write to you because when I > deploy servlet on tomcat it can't found the ejb name. > > My situation is: > > My Platform is RedHat Linux 7.1 runs intel PIII 800 > > My java version is 1.3.1-b24 > > I seperate download and install jboss 2.4.3 and tomcat 4.0.1 in binary > version. I didn't use embed tomcat in jobss solution, because that is > not > the really situation in industry, it is violate distributed computing > principle. > > I installed and run jboss ok, I tested it by using interest examples. I > didn't modify any deploy descriptors that included ejb-jar.xml and > jboss.xml that mean the ejb name should be "Interesr" and jndi name > should be "interest/Interest". The auto deploy is well, and I run the > client > application InterestClient to access the ejb is ok, That mean ejb > deploy is OK. > > Then I follow howto "Tomcat - Jboss HOWTO V1.2" copy necassary lib to > ${tomcat_home}/webapps/jboss/MEB_INF/lib and copy all > run time dependent class under > ${tomcat_home}/webapps/jboss/MEB_INF/classes. I config the servlet > environment by modifying > ${tomcat_home}/webapps/jboss/WEB-INF/web.xml by adding lines like > > <!-- added by cidy for jboss work --> > <context-param> > <param-name>java.naming.factory.initial</param-name> > <!-- for jnp > <param-value>org.jnp.interfaces.NamingContextFactory</param-value> > --> > <param-value>com.sun.jndi.rmi.registry.RegistryContextFactory</param-value> > > </context-param> > > <context-param> > <param-name>java.naming.provider.url</param-name> > <!-- jnp only > <param-value>jnp://localhost:1099</param-value> > --> > <param-value>rmi://localhost:1099</param-value> > </context-param> > <!-- java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces > --> > <!-- > <context-param> > <param-name>java.naming.factory.url.pkgs</param-name> > <param-value>org.jboss.naming:org.jnp.interfaces</param-value> > </context-param> > --> > <!-- add finished here --> > <servlet> > <servlet-name>InterestServlet</servlet-name> > > <servlet-class>org.jboss.docs.interest.InterestServlet</servlet-class> > </servlet> > > I also modified the <tomcat home>/conf/server.xml: by adding following > line > > <RequestInterceptor > className="org.apache.tomcat.request.Jdk12Interceptor" /> > > in same module, I put a servlet called snoopServlet that can figure out > the servlet environment. after call that servlet and showed the > environment is ok, the result like: > > Servlet init parameters: > > Context init parameters: > java.naming.factory.initial = > com.sun.jndi.rmi.registry.RegistryContextFactory > java.naming.provider.url = rmi://localhost:1099 > > Context attributes: > javax.servlet.context.tempdir = > /mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/work/localhost/jboss > org.apache.catalina.resources = > org.apache.naming.resources.ProxyDirContext@6c8909 > org.apache.catalina.WELCOME_FILES = [Ljava.lang.String;@18c56d > org.apache.catalina.jsp_classpath = > >/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/webapps/jboss/WEB-INF/classes/:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/webapps/jboss/WEB-INF/lib/jboss-client.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/webapps/jboss/WEB-INF/lib/jboss-j2ee.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/webapps/jboss/WEB-INF/lib/jbosssx-client.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/webapps/jboss/WEB-INF/lib/jnp-client.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/classes/:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/lib/jasper-runtime.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/lib/naming-factory.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/lib/jasper-compiler.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/classes/:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/activation.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/xerces.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/tyrex-0.9.7.0.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/jdbc2_0-stdext.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/servlet.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/mail.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/jta.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/naming-resources.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/naming-common.jar:/mnt/localdr/app/tomcat/jakarta-tomcat-4.0.1/common/lib/rmiregistry.jar > > Then I code and compile the InterestServlet that I put it in the > attachment please find it > > The compile is ok. I put some debug information is code, so I can > monitor the program is going. when I invoked that servlet, the error > message is come out like: > > 2001-11-01 09:23:07 invoker: Cannot allocate servlet instance for path > /jboss/servlet/InterestServlet > javax.servlet.ServletException: Failed to lookup java:comp/env/Interest > at > org.jboss.docs.interest.InterestServlet.init(InterestServlet.java:72) > at javax.servlet.GenericServlet.init(GenericServlet.java:258) > at > org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852) > at > org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615) > > at > org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:396) > > at > org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) > > at > >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) > > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) > > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) > > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > >org.apache.catalina.connector.warp.WarpRequestHandler.handle(WarpRequestHandler.java:215) > > at > org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:194) > > at java.lang.Thread.run(Thread.java:484) > ----- Root Cause ----- > javax.naming.NameNotFoundException: Name Interest is not bound in this > Context > at org.apache.naming.NamingContext.lookup(NamingContext.java:811) > at org.apache.naming.NamingContext.lookup(NamingContext.java:181) > at org.apache.naming.NamingContext.lookup(NamingContext.java:822) > at org.apache.naming.NamingContext.lookup(NamingContext.java:181) > at org.apache.naming.NamingContext.lookup(NamingContext.java:822) > at org.apache.naming.NamingContext.lookup(NamingContext.java:194) > at org.apache.naming.SelectorContext.lookup(SelectorContext.java:183) > at javax.naming.InitialContext.lookup(InitialContext.java:350) > at > org.jboss.docs.interest.InterestServlet.init(InterestServlet.java:65) > at javax.servlet.GenericServlet.init(GenericServlet.java:258) > at > org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:852) > at > org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:615) > > at > org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:396) > > at > org.apache.catalina.servlets.InvokerServlet.doGet(InvokerServlet.java:180) > > at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) > at > >org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247) > > at > >org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193) > > at > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344) > > at > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) > > at > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163) > > at > org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566) > > at > org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) > > at > org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) > at > >org.apache.catalina.connector.warp.WarpRequestHandler.handle(WarpRequestHandler.java:215) > > at > org.apache.catalina.connector.warp.WarpConnection.run(WarpConnection.java:194) > > at java.lang.Thread.run(Thread.java:484) > > The log tell me > > Starting service Tomcat-Standalone > Apache Tomcat/4.0.1 > Starting service Tomcat-Apache > Apache Tomcat/4.0.1 > jjjkkk > jndi name look up fail!! > javax.naming.NameNotFoundException: Name Interest is not bound in this > Context > > looks like jndi found comp/env/ but it can't found following name. If I > lookup with java:/comp/env/ejb/Ineterest the error message say > > avax.naming.NameNotFoundException: Name ejb is not bound in this > Context. > > I ever try two jndi services as jnp and sun, but the results are same, > > when I use http://localhost:8082 to view the registried ejb I get > information is strange, the ejb was registried under Management and the > name become jnidName, I had post to you with this mail, please find > attachment. > > So I don't know how I can get thing right. > > I am sorry this maybe waste your time, But I really hope you can help > me. > > Best regards > > Cidy Long > > appendix > > package org.jboss.docs.interest; > > import java.io.IOException; > import java.io.PrintWriter; > import java.util.Hashtable; > import java.util.Properties; > import javax.naming.Context; > import javax.naming.InitialContext; > import javax.rmi.PortableRemoteObject; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import org.jboss.docs.interest.Interest; > import org.jboss.docs.interest.InterestHome; > > /** > * This Servlet provides a user interface to an Enterprise Java Bean. > * The example EJB described in the jBoss documentation at > * http://jboss.org/ calculates compound interest. > * This servlet will call the Interest EJB, passing it a few > * parameters. The EJB will return a result, which the servlet > * will display to the Web client. > */ > public class InterestServlet extends HttpServlet > { > private InterestHome interestHome = null; > > /** Looks up the InterestHome interface and saves it for use in > doGet(). > */ > public void init() throws ServletException > { > // Set properties > Properties newProps = System.getProperties(); > newProps.put ("java.naming.factory.initial", > getServletContext().getInitParameter ("java.naming.factory.initial")); > newProps.put ("java.naming.provider.url", > getServletContext().getInitParameter ("java.naming.provider.url")); > System.setProperties (newProps); > //newProps.put ("java.naming.factory.url.pkgs", > getServletContext().getInitParameter ("java.naming.factory.url.pkgs")); > //System.setProperties (newProps); > //AnEJB gocha = null; > //String url="iiop://localhost:1099/"; > //Hashtable env = new Hashtable(); > //env.put(Context.INITIAL_CONTEXT_FACTORY, > // "com.sun.jndi.fscontext.RefFSContextFactory"); > //env.put(Context.PROVIDER_URL,url); > > String ejbString="java:comp/env/Interest"; > Object ref=null; > try{ > // Get a naming context > //String url="localhost:1099/"; > //String url="iiop://187.11.1.89:1050/"; > //Hashtable env = new Hashtable(); > > >//env.put(javax.naming.factory.initial,"org.jnp.interfaces.NamingContextFactory");//jboss > > //env.put(javax.naming.provider.url,url); > > //env.put(javax.naming.factory.url.pkgs,"org.jboss.naming:org.jnp.interfaces"); > > //InitialContext initial = new InitialContext(env); > InitialContext jndiContext = new InitialContext(newProps); > System.out.println("jjjkkk"); > // Get a reference to the Interest Bean > //Object ref = > jndiContext.lookup("java:comp/env/ejb/Interest"); commented out by > cidy to try > ref = (Object)jndiContext.lookup(ejbString); > // Get a reference from this to the Bean's Home interface > //interestHome = (InterestHome) PortableRemoteObject.narrow(ref, > InterestHome.class); > } > catch(Exception e){ > System.out.println("jndi name look up fail!!"); > System.out.println(e.toString()); > throw new ServletException("Failed to lookup "+ejbString, e); > } > try { > interestHome = (InterestHome) PortableRemoteObject.narrow(ref, > InterestHome.class); > } > catch(Exception e){ > System.out.println("create home object fail!!"); > throw new ServletException("create home object fail in servlet ", > e); > } > } > > /** > */ > public void doPost(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException > { > String title = "Servlet interface to EJB"; > double principal = getValue("principal", 1000.0, request); > double rate = getValue("rate", 10.0, request); > double periods = getValue("periods", 2.0, request); > // set content type and other response header fields first > response.setContentType("text/html"); > // then write the data of the response > PrintWriter out = response.getWriter(); > > out.println("<HTML><HEAD><TITLE>"); > out.println(title); > out.println("</TITLE></HEAD><BODY>"); > out.println("<H1>" + title + "</H1>"); > out.println("<H2>Calling EJB...</H2>"); > > try > { > // Create an Interest object from the Home interface > Interest bean = interestHome.create(); > // call the calculateCompoundInterest() method to do the > calculation > out.print("Interest on "+principal); > out.print(" units, at "+rate); > out.print("% per period, compounded over "+periods); > out.println(" periods is: "); > out.println(bean.calculateCompoundInterest(principal, rate/100, > periods)); > bean.remove(); > } > catch(Exception e) > { > out.println(e.toString()); > } > finally > { > out.println("</BODY></HTML>"); > out.close(); > } > } > > private double getValue(String name, double defaultValue, > HttpServletRequest request) > { > double value = defaultValue; > String pvalue = request.getParameter(name); > if( pvalue != null ) > { > try > { > value = Double.valueOf(pvalue).doubleValue(); > } > catch(NumberFormatException e) > { > } > } > return value; > } > } > > package org.jboss.docs.interest; > > import java.io.IOException; > import java.io.PrintWriter; > import java.util.Hashtable; > import java.util.Properties; > import javax.naming.Context; > import javax.naming.InitialContext; > import javax.rmi.PortableRemoteObject; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import org.jboss.docs.interest.Interest; > import org.jboss.docs.interest.InterestHome; > > /** > * This Servlet provides a user interface to an Enterprise Java Bean. > * The example EJB described in the jBoss documentation at > * http://jboss.org/ calculates compound interest. > * This servlet will call the Interest EJB, passing it a few > * parameters. The EJB will return a result, which the servlet > * will display to the Web client. > */ > public class InterestServlet extends HttpServlet > { > private InterestHome interestHome = null; > > /** Looks up the InterestHome interface and saves it for use in > doGet(). > */ > public void init() throws ServletException > { > // Set properties > Properties newProps = System.getProperties(); > newProps.put ("java.naming.factory.initial", > getServletContext().getInitParameter ("java.naming.factory.initial")); > newProps.put ("java.naming.provider.url", > getServletContext().getInitParameter ("java.naming.provider.url")); > System.setProperties (newProps); > String ejbString="java:comp/env/Interest"; > Object ref=null; > try{ > InitialContext jndiContext = new InitialContext(newProps); > System.out.println("jjjkkk"); > > ref = (Object)jndiContext.lookup(ejbString); > } > catch(Exception e){ > System.out.println("jndi name look up fail!!"); > System.out.println(e.toString()); > throw new ServletException("Failed to lookup "+ejbString, e); > > } > try { > interestHome = (InterestHome) > PortableRemoteObject.narrow(ref, InterestHome.class); > } > catch(Exception e){ > System.out.println("create home object fail!!"); > throw new ServletException("create home object fail in > servlet ", e); > } > } > > /** > */ > public void doPost(HttpServletRequest request, HttpServletResponse > response) > throws ServletException, IOException > { > String title = "Servlet interface to EJB"; > double principal = getValue("principal", 1000.0, request); > double rate = getValue("rate", 10.0, request); > double periods = getValue("periods", 2.0, request); > // set content type and other response header fields first > response.setContentType("text/html"); > // then write the data of the response > PrintWriter out = response.getWriter(); > > out.println("<HTML><HEAD><TITLE>"); > out.println(title); > out.println("</TITLE></HEAD><BODY>"); > out.println("<H1>" + title + "</H1>"); > out.println("<H2>Calling EJB...</H2>"); > > try > { > // Create an Interest object from the Home interface > Interest bean = interestHome.create(); > // call the calculateCompoundInterest() method to do the > calculation > out.print("Interest on "+principal); > out.print(" units, at "+rate); > out.print("% per period, compounded over "+periods); > out.println(" periods is: "); > out.println(bean.calculateCompoundInterest(principal, rate/100, > periods)); > bean.remove(); > } > catch(Exception e) > { > out.println(e.toString()); > } > finally > { > out.println("</BODY></HTML>"); > out.close(); > } > } > > private double getValue(String name, double defaultValue, > HttpServletRequest request) > { > double value = defaultValue; > String pvalue = request.getParameter(name); > if( pvalue != null ) > { > try > { > value = Double.valueOf(pvalue).doubleValue(); > } > catch(NumberFormatException e) > { > } > } > return value; > } > } > > ------------------------------------------------------------------------ > package org.jboss.docs.interest; > > import java.io.IOException; > import java.io.PrintWriter; > import java.util.Hashtable; > import java.util.Properties; > import javax.naming.Context; > import javax.naming.InitialContext; > import javax.rmi.PortableRemoteObject; > import javax.servlet.ServletException; > import javax.servlet.http.HttpServlet; > import javax.servlet.http.HttpServletRequest; > import javax.servlet.http.HttpServletResponse; > > import org.jboss.docs.interest.Interest; > import org.jboss.docs.interest.InterestHome; > > /** > * This Servlet provides a user interface to an Enterprise Java Bean. > * The example EJB described in the jBoss documentation at > * http://jboss.org/ calculates compound interest. > * This servlet will call the Interest EJB, passing it a few > * parameters. The EJB will return a result, which the servlet > * will display to the Web client. > */ > public class InterestServlet extends HttpServlet > { > private InterestHome interestHome = null; > > /** Looks up the InterestHome interface and saves it for use in > doGet(). > */ > public void init() throws ServletException > { > // Set properties > Properties newProps = System.getProperties(); > newProps.put ("java.naming.factory.initial", >getServletContext().getInitParameter ("java.naming.factory.initial")); > newProps.put ("java.naming.provider.url", >getServletContext().getInitParameter ("java.naming.provider.url")); > System.setProperties (newProps); > String ejbString="java:comp/env/Interest"; > Object ref=null; > try{ > InitialContext jndiContext = new InitialContext(newProps); > System.out.println("jjjkkk"); > > ref = (Object)jndiContext.lookup(ejbString); > } > catch(Exception e){ > System.out.println("jndi name look up fail!!"); > System.out.println(e.toString()); > throw new ServletException("Failed to lookup "+ejbString, e); > } > try { > interestHome = (InterestHome) PortableRemoteObject.narrow(ref, >InterestHome.class); > } > catch(Exception e){ > System.out.println("create home object fail!!"); > throw new ServletException("create home object fail in servlet ", e); > } > } > > /** > */ > public void doPost(HttpServletRequest request, HttpServletResponse response) > throws ServletException, IOException > { > String title = "Servlet interface to EJB"; > double principal = getValue("principal", 1000.0, request); > double rate = getValue("rate", 10.0, request); > double periods = getValue("periods", 2.0, request); > // set content type and other response header fields first > response.setContentType("text/html"); > // then write the data of the response > PrintWriter out = response.getWriter(); > > out.println("<HTML><HEAD><TITLE>"); > out.println(title); > out.println("</TITLE></HEAD><BODY>"); > out.println("<H1>" + title + "</H1>"); > out.println("<H2>Calling EJB...</H2>"); > > try > { > // Create an Interest object from the Home interface > Interest bean = interestHome.create(); > // call the calculateCompoundInterest() method to do the calculation > out.print("Interest on "+principal); > out.print(" units, at "+rate); > out.print("% per period, compounded over "+periods); > out.println(" periods is: "); > out.println(bean.calculateCompoundInterest(principal, rate/100, periods)); > bean.remove(); > } > catch(Exception e) > { > out.println(e.toString()); > } > finally > { > out.println("</BODY></HTML>"); > out.close(); > } > } > > private double getValue(String name, double defaultValue, HttpServletRequest >request) > { > double value = defaultValue; > String pvalue = request.getParameter(name); > if( pvalue != null ) > { > try > { > value = Double.valueOf(pvalue).doubleValue(); > } > catch(NumberFormatException e) > { > } > } > return value; > } > } > > ------------------------------------------------------------------------ > [Image] _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com