jsp page giving error on tomcat 5  
Author Message
thisislalit





PostPosted: 2004-4-19 12:34:00 Top

java-programmer, jsp page giving error on tomcat 5 Hi

i have written a class for database connection. It has two public
functions connect() which return an object of class Connection and
function close which close the connection

I am using that class in a jsp page to connect to database, but I am
getting an error :

Generated servlet error:
[javac] Compiling 1 source file

/usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
package db does not exist
import db.*;
^
/usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
cannot resolve symbol
symbol : variable ibDriverTest
location: class org.apache.jsp.web.jsp.index_jsp
Connection con = ibDriverTest.connect();
......


The class is in the package db. Can you please tell why is import db.*
not working.


Thanks is advance

Lalit
 
thisislalit





PostPosted: 2004-4-19 13:04:00 Top

java-programmer >> jsp page giving error on tomcat 5 i am using tomcat 5.0.19 on linux and have created a class in package
db to connect the database that has function that returns the
Connection object. when I compile it using ant it works fine but when
used in jsp page it gves an error "package db does not exist:
import.db.*". Could someone help me to solve this problem
 
cbroussard





PostPosted: 2004-4-20 20:36:00 Top

java-programmer >> jsp page giving error on tomcat 5 looks like a classpath issue... or a jsp syntax problem.

for the classpath make sure you have a compiled class file in
WEB-INF/classes or a jar file contianing necessary files in
WEB-INF/lib.

as far as the syntax... hard to see it w/out your code... but looks
like your syntax may be this:
index.jsp
_________
import db.*;

should be index.jsp
-------------------

<%@ page import="db.*" %>


as a side note i would recommend a little more standard package
convention. this is a little nit-picky but it's good to have more
descriptive package names. especially helpful if you application
grows then you don't have to refactor.

com.sitename.project.db or
com.sitename.project.commons.db



email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> Hi
>
> i have written a class for database connection. It has two public
> functions connect() which return an object of class Connection and
> function close which close the connection
>
> I am using that class in a jsp page to connect to database, but I am
> getting an error :
>
> Generated servlet error:
> [javac] Compiling 1 source file
>
> /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
> package db does not exist
> import db.*;
> ^
> /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
> cannot resolve symbol
> symbol : variable ibDriverTest
> location: class org.apache.jsp.web.jsp.index_jsp
> Connection con = ibDriverTest.connect();
> ......
>
>
> The class is in the package db. Can you please tell why is import db.*
> not working.
>
>
> Thanks is advance
>
> Lalit
 
 
thisislalit





PostPosted: 2004-4-20 23:56:00 Top

java-programmer >> jsp page giving error on tomcat 5 i am using tomcat 5.0.19 on linux and have created a class in package
named
"db" to connect the database that has function that returns the
Connection object. when I compile it using ant it works compile
without error fine but when used in jsp page it gves an error
"package db does not exist: import.db.*".

I tried to add $CATALINA_HOME/webapp/web/WEB-INF/classes to the
classpath too!

Could someone help me to solve this problem
 
 
Christophe Vanfleteren





PostPosted: 2004-4-21 2:33:00 Top

java-programmer >> jsp page giving error on tomcat 5 Lalit wrote:

> i am using tomcat 5.0.19 on linux and have created a class in package
> named
> "db" to connect the database that has function that returns the
> Connection object. when I compile it using ant it works compile
> without error fine but when used in jsp page it gves an error
> "package db does not exist: import.db.*".

Is that the exact error message?

Could you show the code where you import the classes in your jsp?
It should look like
<%@page import="db.*"%>

> I tried to add $CATALINA_HOME/webapp/web/WEB-INF/classes to the
> classpath too!

That is unnecessary, Tomcat ignores any CLASSPATH settings.

--
Kind regards,
Christophe Vanfleteren
 
 
thisislalit





PostPosted: 2004-4-21 2:40:00 Top

java-programmer >> jsp page giving error on tomcat 5 Thats absolutely correct.
I have compiled and the class file is in WEB-INF/classes
The file name I am calling is index.jsp
And it says <%@ page import="db.*" %>

Also, I will take care that I use better package names. Thanks for the tip.

Still it is not working, I get the same error.

To detect the problem, I have the following structure (if that helps.)

webapps
|_tst
|_docs
|_src
| |_classes
| | |_db
| | |_DriverTest.java
| |
| |_servlets
|
|_web
| |_WEB-INF
| | |_classes
| | |_db
| | |_DriverTest.class
| |_jsp
| |_index.jsp
|
|_build.xml

Please let me know where I am going wrong. This is driving me nuts.

Thanks,
Lalit

email***@***.com (Chris) wrote in message news:<email***@***.com>...
> looks like a classpath issue... or a jsp syntax problem.
>
> for the classpath make sure you have a compiled class file in
> WEB-INF/classes or a jar file contianing necessary files in
> WEB-INF/lib.
>
> as far as the syntax... hard to see it w/out your code... but looks
> like your syntax may be this:
> index.jsp
> _________
> import db.*;
>
> should be index.jsp
> -------------------
>
> <%@ page import="db.*" %>
>
>
> as a side note i would recommend a little more standard package
> convention. this is a little nit-picky but it's good to have more
> descriptive package names. especially helpful if you application
> grows then you don't have to refactor.
>
> com.sitename.project.db or
> com.sitename.project.commons.db
>
>
>
> email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > Hi
> >
> > i have written a class for database connection. It has two public
> > functions connect() which return an object of class Connection and
> > function close which close the connection
> >
> > I am using that class in a jsp page to connect to database, but I am
> > getting an error :
> >
> > Generated servlet error:
> > [javac] Compiling 1 source file
> >
> > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
> > package db does not exist
> > import db.*;
> > ^
> > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
> > cannot resolve symbol
> > symbol : variable ibDriverTest
> > location: class org.apache.jsp.web.jsp.index_jsp
> > Connection con = ibDriverTest.connect();
> > ......
> >
> >
> > The class is in the package db. Can you please tell why is import db.*
> > not working.
> >
> >
> > Thanks is advance
> >
> > Lalit
 
 
mbierwirth





PostPosted: 2004-4-21 15:25:00 Top

java-programmer >> jsp page giving error on tomcat 5 email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> Thats absolutely correct.
> I have compiled and the class file is in WEB-INF/classes
> The file name I am calling is index.jsp
> And it says <%@ page import="db.*" %>
>
> Also, I will take care that I use better package names. Thanks for the tip.
>
> Still it is not working, I get the same error.
>
> To detect the problem, I have the following structure (if that helps.)
>
> webapps
> |_tst
> |_docs
> |_src
> | |_classes
> | | |_db
> | | |_DriverTest.java
> | |
> | |_servlets
> |
> |_web
> | |_WEB-INF
> | | |_classes
> | | |_db
> | | |_DriverTest.class
> | |_jsp
> | |_index.jsp
> |
> |_build.xml

AFAIK this is not standard structure. If your web-application is
'tst', I'd put the folder WEB-INF directly below '../webapps/tst'.

Martin

>
> Please let me know where I am going wrong. This is driving me nuts.
>
> Thanks,
> Lalit
>
> email***@***.com (Chris) wrote in message news:<email***@***.com>...
> > looks like a classpath issue... or a jsp syntax problem.
> >
> > for the classpath make sure you have a compiled class file in
> > WEB-INF/classes or a jar file contianing necessary files in
> > WEB-INF/lib.
> >
> > as far as the syntax... hard to see it w/out your code... but looks
> > like your syntax may be this:
> > index.jsp
> > _________
> > import db.*;
> >
> > should be index.jsp
> > -------------------
> >
> > <%@ page import="db.*" %>
> >
> >
> > as a side note i would recommend a little more standard package
> > convention. this is a little nit-picky but it's good to have more
> > descriptive package names. especially helpful if you application
> > grows then you don't have to refactor.
> >
> > com.sitename.project.db or
> > com.sitename.project.commons.db
> >
> >
> >
> > email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > > Hi
> > >
> > > i have written a class for database connection. It has two public
> > > functions connect() which return an object of class Connection and
> > > function close which close the connection
> > >
> > > I am using that class in a jsp page to connect to database, but I am
> > > getting an error :
> > >
> > > Generated servlet error:
> > > [javac] Compiling 1 source file
> > >
> > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
> > > package db does not exist
> > > import db.*;
> > > ^
> > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
> > > cannot resolve symbol
> > > symbol : variable ibDriverTest
> > > location: class org.apache.jsp.web.jsp.index_jsp
> > > Connection con = ibDriverTest.connect();
> > > ......
> > >
> > >
> > > The class is in the package db. Can you please tell why is import db.*
> > > not working.
> > >
> > >
> > > Thanks is advance
> > >
> > > Lalit
 
 
cbroussard





PostPosted: 2004-4-22 0:15:00 Top

java-programmer >> jsp page giving error on tomcat 5 -- Martin is right...

you need webapps->tst->WEB-INF... part of the jsp/servlet spec is to
have that in it's proper location.

i also recommend you restructure your application, and pull out all
your src directories. if you aren't familiar w/ ANT i would take a
look ant.apache.org.
i would use that as your build mechanism from src->webapps.

hope that helps.


email***@***.com (Martin) wrote in message news:<email***@***.com>...
> email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > Thats absolutely correct.
> > I have compiled and the class file is in WEB-INF/classes
> > The file name I am calling is index.jsp
> > And it says <%@ page import="db.*" %>
> >
> > Also, I will take care that I use better package names. Thanks for the tip.
> >
> > Still it is not working, I get the same error.
> >
> > To detect the problem, I have the following structure (if that helps.)
> >
> > webapps
> > |_tst
> > |_docs
> > |_src
> > | |_classes
> > | | |_db
> > | | |_DriverTest.java
> > | |
> > | |_servlets
> > |
> > |_web
> > | |_WEB-INF
> > | | |_classes
> > | | |_db
> > | | |_DriverTest.class
> > | |_jsp
> > | |_index.jsp
> > |
> > |_build.xml
>
> AFAIK this is not standard structure. If your web-application is
> 'tst', I'd put the folder WEB-INF directly below '../webapps/tst'.
>
> Martin
>
> >
> > Please let me know where I am going wrong. This is driving me nuts.
> >
> > Thanks,
> > Lalit
> >
> > email***@***.com (Chris) wrote in message news:<email***@***.com>...
> > > looks like a classpath issue... or a jsp syntax problem.
> > >
> > > for the classpath make sure you have a compiled class file in
> > > WEB-INF/classes or a jar file contianing necessary files in
> > > WEB-INF/lib.
> > >
> > > as far as the syntax... hard to see it w/out your code... but looks
> > > like your syntax may be this:
> > > index.jsp
> > > _________
> > > import db.*;
> > >
> > > should be index.jsp
> > > -------------------
> > >
> > > <%@ page import="db.*" %>
> > >
> > >
> > > as a side note i would recommend a little more standard package
> > > convention. this is a little nit-picky but it's good to have more
> > > descriptive package names. especially helpful if you application
> > > grows then you don't have to refactor.
> > >
> > > com.sitename.project.db or
> > > com.sitename.project.commons.db
> > >
> > >
> > >
> > > email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > > > Hi
> > > >
> > > > i have written a class for database connection. It has two public
> > > > functions connect() which return an object of class Connection and
> > > > function close which close the connection
> > > >
> > > > I am using that class in a jsp page to connect to database, but I am
> > > > getting an error :
> > > >
> > > > Generated servlet error:
> > > > [javac] Compiling 1 source file
> > > >
> > > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
> > > > package db does not exist
> > > > import db.*;
> > > > ^
> > > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
> > > > cannot resolve symbol
> > > > symbol : variable ibDriverTest
> > > > location: class org.apache.jsp.web.jsp.index_jsp
> > > > Connection con = ibDriverTest.connect();
> > > > ......
> > > >
> > > >
> > > > The class is in the package db. Can you please tell why is import db.*
> > > > not working.
> > > >
> > > >
> > > > Thanks is advance
> > > >
> > > > Lalit
 
 
thisislalit





PostPosted: 2004-4-23 13:28:00 Top

java-programmer >> jsp page giving error on tomcat 5 Hello Martin and Chris.

Thanks for your prompt response. I tried with the modified structure,
and it works well.

Thanks once again

Lalit



email***@***.com (Chris) wrote in message news:<email***@***.com>...
> -- Martin is right...
>
> you need webapps->tst->WEB-INF... part of the jsp/servlet spec is to
> have that in it's proper location.
>
> i also recommend you restructure your application, and pull out all
> your src directories. if you aren't familiar w/ ANT i would take a
> look ant.apache.org.
> i would use that as your build mechanism from src->webapps.
>
> hope that helps.
>
>
> email***@***.com (Martin) wrote in message news:<email***@***.com>...
> > email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > > Thats absolutely correct.
> > > I have compiled and the class file is in WEB-INF/classes
> > > The file name I am calling is index.jsp
> > > And it says <%@ page import="db.*" %>
> > >
> > > Also, I will take care that I use better package names. Thanks for the tip.
> > >
> > > Still it is not working, I get the same error.
> > >
> > > To detect the problem, I have the following structure (if that helps.)
> > >
> > > webapps
> > > |_tst
> > > |_docs
> > > |_src
> > > | |_classes
> > > | | |_db
> > > | | |_DriverTest.java
> > > | |
> > > | |_servlets
> > > |
> > > |_web
> > > | |_WEB-INF
> > > | | |_classes
> > > | | |_db
> > > | | |_DriverTest.class
> > > | |_jsp
> > > | |_index.jsp
> > > |
> > > |_build.xml
> >
> > AFAIK this is not standard structure. If your web-application is
> > 'tst', I'd put the folder WEB-INF directly below '../webapps/tst'.
> >
> > Martin
> >
> > >
> > > Please let me know where I am going wrong. This is driving me nuts.
> > >
> > > Thanks,
> > > Lalit
> > >
> > > email***@***.com (Chris) wrote in message news:<email***@***.com>...
> > > > looks like a classpath issue... or a jsp syntax problem.
> > > >
> > > > for the classpath make sure you have a compiled class file in
> > > > WEB-INF/classes or a jar file contianing necessary files in
> > > > WEB-INF/lib.
> > > >
> > > > as far as the syntax... hard to see it w/out your code... but looks
> > > > like your syntax may be this:
> > > > index.jsp
> > > > _________
> > > > import db.*;
> > > >
> > > > should be index.jsp
> > > > -------------------
> > > >
> > > > <%@ page import="db.*" %>
> > > >
> > > >
> > > > as a side note i would recommend a little more standard package
> > > > convention. this is a little nit-picky but it's good to have more
> > > > descriptive package names. especially helpful if you application
> > > > grows then you don't have to refactor.
> > > >
> > > > com.sitename.project.db or
> > > > com.sitename.project.commons.db
> > > >
> > > >
> > > >
> > > > email***@***.com (Lalit) wrote in message news:<email***@***.com>...
> > > > > Hi
> > > > >
> > > > > i have written a class for database connection. It has two public
> > > > > functions connect() which return an object of class Connection and
> > > > > function close which close the connection
> > > > >
> > > > > I am using that class in a jsp page to connect to database, but I am
> > > > > getting an error :
> > > > >
> > > > > Generated servlet error:
> > > > > [javac] Compiling 1 source file
> > > > >
> > > > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:7:
> > > > > package db does not exist
> > > > > import db.*;
> > > > > ^
> > > > > /usr/tomcat/work/Catalina/localhost/tpr/org/apache/jsp/web/jsp/index_jsp.java:51:
> > > > > cannot resolve symbol
> > > > > symbol : variable ibDriverTest
> > > > > location: class org.apache.jsp.web.jsp.index_jsp
> > > > > Connection con = ibDriverTest.connect();
> > > > > ......
> > > > >
> > > > >
> > > > > The class is in the package db. Can you please tell why is import db.*
> > > > > not working.
> > > > >
> > > > >
> > > > > Thanks is advance
> > > > >
> > > > > Lalit