Link to home
Start Free TrialLog in
Avatar of Xyleen
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.catalina.logger.FileLogger" 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/manager">
|    </Context>
|     </Host>
---------------------------------

If i run the following code on this virtual host :
-------------------------------
|    <%@ page import='java.sql.*,java.text.*,mycompany.fotospecial.*,java.io.*' %>
|    <%@ taglib uri="/WEB-INF/taglib/database.tld" prefix="mycompany"%>
|    <mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnection">
|    <%
|         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 ????

Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

what happens if you change

appBase="c:/wwwroot"

to

appBase="/wwwroot"

?
Avatar of Xyleen
Xyleen

ASKER

my virtual host doesn't work anymore then
Avatar of Xyleen

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.text.*,mycompany.fotospecial.*,java.io.*' %>
<%@ taglib uri="/WEB-INF/taglib/database.tld" prefix="mycompany"%>
<jsp:useBean id="dbConnection" scope="page" class="XXXXXXXX" />
<mycompany:dbconnection name="dbConnection" source="jdbc/mydbconnection">
<%
     TestClass tc = new TestClass (dbConnection);
%>
</mycompany:dbconnection>

replacing XXXXXXXX with the fully qualified name of the class that dbConnection should be?
Avatar of Xyleen

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 ?

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
Avatar of Xyleen

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 :(
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.
Avatar of Xyleen

ASKER

can you explain this, i don't undersand
ASKER CERTIFIED SOLUTION
Avatar of gnoon
gnoon
Flag of Thailand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial