?
Solved

Taglib not working completely in virtual host ... ?

Posted on 2004-11-25
10
Medium Priority
?
277 Views
Last Modified: 2013-11-24
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 ????

0
Comment
Question by:Xyleen
10 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 12673587
what happens if you change

appBase="c:/wwwroot"

to

appBase="/wwwroot"

?
0
 

Author Comment

by:Xyleen
ID: 12673610
my virtual host doesn't work anymore then
0
 

Author Comment

by:Xyleen
ID: 12673629
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 ...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 35

Expert Comment

by:TimYates
ID: 12673659
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?
0
 

Author Comment

by:Xyleen
ID: 12673886
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 ?

0
 
LVL 35

Expert Comment

by:TimYates
ID: 12673905
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
0
 

Author Comment

by:Xyleen
ID: 12673926
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 :(
0
 
LVL 4

Expert Comment

by:Oliver_Dornauf
ID: 12674457
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.
0
 

Author Comment

by:Xyleen
ID: 12674534
can you explain this, i don't undersand
0
 
LVL 16

Accepted Solution

by:
gnoon earned 600 total points
ID: 12712533
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">
    <sql:url>jdbc:odbc:myproject</sql:url>
    <sql:driver>sun.jdbc.odbc.JdbcOdbcDriver</sql:driver>
    <sql:userId>admin</sql:userId>
    <sql:password>myadmin</sql:password>
</sql:connection>

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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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.

809 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