On 2002-05-09 3:16:21 "Craig R. McClanahan" wrote:
> It would be helpful if you could post the JavaBean class you created, the
> JSP page you are trying this from, and the server.xml and web.xml settings
> you actually used (or send them to me privately).  Is that possible?

I pretty much used what was in the example.  But here they are:

[ MyBean.java BEGIN: ]

package testdbcp ;

public class MyBean {

        private String foo = "Default Foo";
        private int bar = 0;

        public String getFoo() { return (this.foo); }
        public void setFoo(String foo) { this.foo = foo; }


        public int getBar() { return (this.bar); }
        public void setBar(int bar) { this.bar = bar; }

}

[ MyBean.java END ]

[ Jsp1.jsp BEGIN: ]

<%@ page language="java" import="testdbcp.*, javax.naming.*" %>
<%

Context initCtx = new InitialContext() ;
Context envCtx = (Context) initCtx.lookup("java:comp/env") ;
MyBean bean = (MyBean) envCtx.lookup("bean/MyBeanFactory") ;

out.println("foo = " + bean.getFoo() + ", bar = " + bean.getBar()) ;

%>

[ Jsp1.jsp END ]

[ server.xml BEGIN: ]

<?xml version="1.0" encoding="UTF-8"?>
<Server debug="0" port="8081" shutdown="SHUTDOWN">
<Service name="Tomcat-Standalone">
<Connector acceptCount="10"
className="org.apache.catalina.connector.http.HttpConnector"
connectionTimeout="60000" debug="0" maxProcessors="75"
minProcessors="5" port="8080"/>
<Engine debug="0" defaultHost="localhost" name="Standalone">
<Host appBase="C:\Documents and Settings\Anthony\jbproject\testDBCP\conf"
debug="0" name="localhost" unpackWARs="false">
<Context debug="0"
docBase="C:/Documents and Settings/Anthony/jbproject/testDBCP/defaultroot"
path="" workDir="C:/Documents and
Settings/Anthony/jbproject/testDBCP/work"/>
<Context debug="0"
docBase="C:/Documents and Settings/Anthony/jbproject/testDBCP/context"
path="/testDBCP"
workDir="C:/Documents and
Settings/Anthony/jbproject/testDBCP/work/testDBCP">
<Resource name="bean/MyBeanFactory" auth="Container"
type="testdbcp.MyBean"/>
<ResourceParams name="bean/MyBeanFactory">
<parameter>
<name>factory</name>
<value>org.apache.naming.factory.BeanFactory</value>
</parameter>
<parameter>
<name>bar</name>
<value>23</value>
</parameter>
</ResourceParams>
</Context>
</Host>
</Engine>
</Service>
</Server>

[ server.xml END ]

[ web.xml BEGIN ]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd";>
<web-app>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<resource-env-ref>
<resource-env-ref-name>bean/MyBeanFactory</resource-env-ref-name>
<resource-env-ref-type>testdbcp.MyBean</resource-env-ref-type>
</resource-env-ref>
</web-app>

[ web.xml END ]

> Craig

Anthony

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to