Xyleen
asked on
Taglib not working completely in virtual host ... ?
Hello,
I'm facing a stiff problem.
My taglib is not working completely on a virtual host i've just configured.
-------------------------- --------
| <Host name="www.sprinter" debug="1" appBase="c:/wwwroot" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
| <Logger className="org.apache.cata lina.logge r.FileLogg er" directory="logs" prefix="www." suffix=".txt" timestamp="true"/>
| <Context path="" docBase="" debug="1" reloadable="true" crossContext="true" />
| <Context path="/manager" debug="0" privileged="true" docBase="c:/tomcat/server/ webapps/ma nager">
| </Context>
| </Host>
-------------------------- -------
If i run the following code on this virtual host :
-------------------------- -----
| <%@ page import='java.sql.*,java.te xt.*,mycom pany.fotos pecial.*,j ava.io.*' %>
| <%@ taglib uri="/WEB-INF/taglib/datab ase.tld" prefix="mycompany"%>
| <mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnectio n">
| <%
| TestClass tc = new TestClass (dbConnection);
| %>
| </mycompany:dbconnection>
-------------------------
If i run this code on my default host it works fine.
In my virtual it gives the following error :
---------------------
| Generated servlet error:
| C:\tomcat\work\Catalina\www.sprinter\_\org\apache\jsp\test_jsp.java:79: cannot resolve | symbol
| symbol : variable dbConnection
| location: class org.apache.jsp.test_jsp
| TestClass vfsi = new TestClass (dbConnection);
| ^
| 1 error
------------------------
When i leave out the TestClass vfsi = new TestClass (dbConnection); code it works fine and my connection is called (i can check this in the logs).
I think i have to add something to my virtual host configuration but what ????
I'm facing a stiff problem.
My taglib is not working completely on a virtual host i've just configured.
--------------------------
| <Host name="www.sprinter" debug="1" appBase="c:/wwwroot" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
| <Logger className="org.apache.cata
| <Context path="" docBase="" debug="1" reloadable="true" crossContext="true" />
| <Context path="/manager" debug="0" privileged="true" docBase="c:/tomcat/server/
| </Context>
| </Host>
--------------------------
If i run the following code on this virtual host :
--------------------------
| <%@ page import='java.sql.*,java.te
| <%@ taglib uri="/WEB-INF/taglib/datab
| <mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnectio
| <%
| TestClass tc = new TestClass (dbConnection);
| %>
| </mycompany:dbconnection>
-------------------------
If i run this code on my default host it works fine.
In my virtual it gives the following error :
---------------------
| Generated servlet error:
| C:\tomcat\work\Catalina\www.sprinter\_\org\apache\jsp\test_jsp.java:79: cannot resolve | symbol
| symbol : variable dbConnection
| location: class org.apache.jsp.test_jsp
| TestClass vfsi = new TestClass (dbConnection);
| ^
| 1 error
------------------------
When i leave out the TestClass vfsi = new TestClass (dbConnection); code it works fine and my connection is called (i can check this in the logs).
I think i have to add something to my virtual host configuration but what ????
ASKER
my virtual host doesn't work anymore then
ASKER
excuse me, i've copied the files from c:/wwwroot to c:/tomcat/webapps/wwwroot and the virtual host is working again but i get the same error ...
Can you try changing your JSP to:
<%@ page import='java.sql.*,java.te xt.*,mycom pany.fotos pecial.*,j ava.io.*' %>
<%@ taglib uri="/WEB-INF/taglib/datab ase.tld" prefix="mycompany"%>
<jsp:useBean id="dbConnection" scope="page" class="XXXXXXXX" />
<mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnectio n">
<%
TestClass tc = new TestClass (dbConnection);
%>
</mycompany:dbconnection>
replacing XXXXXXXX with the fully qualified name of the class that dbConnection should be?
<%@ page import='java.sql.*,java.te
<%@ taglib uri="/WEB-INF/taglib/datab
<jsp:useBean id="dbConnection" scope="page" class="XXXXXXXX" />
<mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnectio
<%
TestClass tc = new TestClass (dbConnection);
%>
</mycompany:dbconnection>
replacing XXXXXXXX with the fully qualified name of the class that dbConnection should be?
ASKER
euhm :
what are you trying to do ?
the name "dbConnection" is now given to the useBean AND to the tag-param
Which one do you want me to pass to the TestClass ?
what are you trying to do ?
the name "dbConnection" is now given to the useBean AND to the tag-param
Which one do you want me to pass to the TestClass ?
No, my thinking is that the "mycompany:dbconnection" tag is not defining the "dbConnection" variable properly in the scope of the page... So putting the useBean tag in will ensure it is defined, and the "mycompany:dbconnection" tag should use the pre-defined bean instead of (wrongly) creating its own...
I *think*
Probably wrong...in which case, ignore me ;-)
Sorry...
Tim
I *think*
Probably wrong...in which case, ignore me ;-)
Sorry...
Tim
ASKER
In that case it wouldn't work either on the default virtual host ....
I changed my code like you said but it doesn't work :(
I changed my code like you said but it doesn't work :(
is the jdbc connection defined in scope of the virtual host?
I had a lot of problems if the connection was defined in global scope.
I had a lot of problems if the connection was defined in global scope.
ASKER
can you explain this, i don't undersand
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
appBase="c:/wwwroot"
to
appBase="/wwwroot"
?