Taglib not working completely in virtual host ... ?

Posted on 2004-11-25
Last Modified: 2013-11-24

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.*,*' %>
|    <%@ 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\ 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 ????

Question by:Xyleen
    LVL 35

    Expert Comment

    what happens if you change





    Author Comment

    my virtual host doesn't work anymore then

    Author Comment

    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 ...
    LVL 35

    Expert Comment

    Can you try changing your JSP to:

    <%@ page import='java.sql.*,java.text.*,mycompany.fotospecial.*,*' %>
    <%@ 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?

    Author Comment

    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 ?

    LVL 35

    Expert Comment

    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 which case, ignore me ;-)



    Author Comment

    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 :(
    LVL 4

    Expert Comment

    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.

    Author Comment

    can you explain this, i don't undersand
    LVL 16

    Accepted Solution

    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

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
    Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
    The viewer will learn how to implement Singleton Design Pattern in Java.
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now