Taglib not working completely in virtual host ... ?


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 ????

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what happens if you change




XyleenAuthor Commented:
my virtual host doesn't work anymore then
XyleenAuthor Commented:
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 ...
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

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);

replacing XXXXXXXX with the fully qualified name of the class that dbConnection should be?
XyleenAuthor Commented:
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 ;-)


XyleenAuthor Commented:
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.
XyleenAuthor Commented:
can you explain this, i don't undersand
I ever used db tags of Jakarta TagLib Project, probably it's not the same as your tag lib.

When I start a database connection on a JSP page, I do this

<%@taglib uri="dbtags" prefix="sql"%>
<sql:connection id="conn1">

Then, when I want to refer to the conn1 connection, I do this

Connection conn1 = (Connection) pageContext.getAttribute("conn1");
if(conn1 != null)

Dont know your tags should be used the same as above?

G noon

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.