You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Bo Xu <bo...@cybershop.ca> on 2001/11/18 22:59:08 UTC

Re: [repost] loading class files

I suggest you put YourApplet.class together with your
html/image or other "static contents), for ex. :
webapps/yourapp0/staticContent/
("staticContent" is a folder made by you)


reference email :-)
------------------------------------------------------------------------
> In which directory of the Tomcat installation do we copy the html and
> applet classes?

I suggest you also read the Application Developer's Guide included with
Tomcat.  The Tomcat 4 version is also online at:

  http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/

>From the point of view of the server, applet classes and JAR files are
just static content.  Therefore, they should be placed in the same
directory as your static HTML pages, ***not*** under /WEB-INF.

> Amit Lonkar
>

Craig McClanahan
------------------------------------------------------------------------



Bo
Nov.18, 2001




----- Original Message -----
From: "Yiu Wing" <yi...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Monday, November 19, 2001 12:41 AM
Subject: [repost] loading class files


> Sorry guys this is a repost. But after doing numerous google search and
> wading through the docs, I still can't solve my problem with regard to
> loading applet classes. I sincerely hope some of you can help me this
time,
> I desperately need to get this working.  The same message is as follow.
>
> Hello All,
>
> I'm writing an applet that uses JDBC to connect to MySQL server , and the
> applet is embedded in a jsp.  I'm new to this, so I went on and read the
> docs that come with Tomcat.  I'm also using CVS and ant for the
development.
> The source code layout of my project is as suggested in the docs, which is
>
> project name
>                   |----- docs
>                   |----- src
>                   |----- web
>                                 |------>WEB-INF
>
> In the project/web/WEB-INF directory, do I have to create a classes and
lib
> subdirectories?  The reason I ask this is because the class loader, from
the
> Tomcat or web browser, can't find the class files.  But they're clearly in
> the web directory, whose structure is as,
>
> project
>           |---- login.jsp (that's the jsp file that embeds the applet)
>           |---- WEB-INF
>                                 |------- classes (this directory has all
the
> needed class files)
>                                 |------- lib (where the MySQL driver is
> stored)
>
> The Tomcat docs says the classes and lib dir "are made visible to other
> classes within your particular web application", but why my class files
> can't be loaded there?  If I move all the class files to the top of the
web
> directory, and change "code="MyClass.class""  to "code="MyClass"" in the
jsp
> file, then everything seems to working OK. Oh, yeah, almost forgot, I also
> need to copy the whole directory tree for the driver to the web directory
as
> well.  Setting the classpath for the driver doesn't work.  I don't want to
> copy the class files to the top of the web directory every time, can those
> file be loaded in the classes and lib directories.  Sorry about this
rather
> long message, but I'm getting very frustrated and hopping some of you can
> help me with this.
>
> Thanks for your help in advance.
>
> P.S. I'm using Tomcat4.0 on Win2000
>
>
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: [repost] loading class files

Posted by Yiu Wing <yi...@yahoo.com>.
[...]
> > But from one of the
> > Tomcat's docs, which is tomcat-docs\appdev\deployment.html, in its mid
> page
> > says,
> >
> > /WEB-INF/lib/ - This directory contains JAR files that contain Java
class
> > files (and associated resources) required for your application, such as
> > third party class libraries or JDBC drivers.
> >
> > I've copied my JDBC driver there, but it just won't work.  My citation
is
> > just the opposite of your reference email, which says that JAR files are
> > static content and can't be place under /WEB-INF.  Since my applet is
> > running now, and so think the docs could be wrong or haven't covered
this
> > topic completely. I hope someone could look this up.
> >
> > Anyway, thanks very much for your email again.  You have saved me!
> >[...]
>
>
> Thanks for your thanking!  :-)

I was very frustrated, I was trying to get this working for a week and I
didn't get anywhere, that's why the big thanks ;-).

> BTW, there are two kinds of class/jar in a webapp:
>   - for Servlet/jsp(it works in server-side)
>   - for Applet or other static content(it will be downloaded to
>     client together with Applet class, and works in client-side)
>
> I think the reference email means:
>    - class/jar for Servlet/jsp itself should be put under WEB-INF
>    - class/jar for static content should Not be put under WEB-INF
>
> I think your JDBC driver is used by your JSP directly, it works in
> server-side, (it is not downloaded together with  your Applat and
> work in client-side), so now, as you say, your JDBC driver should
> be put in WEB-INF/lib.
>

I'm just wondering the JDBC driver is working on the client side, cos' if I
place the driver jar file in WEB-INF/lib directory then it can't be found.
I've also tried the common/lib directory, as the other helpful folk
suggested, and it can't be found there, either.  I've actually embedded my
database connection in the applet, so it does look like I should place the
driver on a separate directory.


[snip]


--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: [repost] loading class files

Posted by Bo Xu <bo...@cybershop.ca>.
----- Original Message -----
From: "Yiu Wing" <yi...@yahoo.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Monday, November 19, 2001 1:58 AM
Subject: Re: [repost] loading class files


> > I suggest you put YourApplet.class together with your
> > html/image or other "static contents), for ex. :
> > webapps/yourapp0/staticContent/
> > ("staticContent" is a folder made by you)
>
> Thanks very much for your reply and reference email. Yeah, I have to
create
> an extra directory to store all my class files, and I also have to
unzipped
> the JDBC driver in order to get my jsp applet running. But from one of the
> Tomcat's docs, which is tomcat-docs\appdev\deployment.html, in its mid
page
> says,
>
> /WEB-INF/lib/ - This directory contains JAR files that contain Java class
> files (and associated resources) required for your application, such as
> third party class libraries or JDBC drivers.
>
> I've copied my JDBC driver there, but it just won't work.  My citation is
> just the opposite of your reference email, which says that JAR files are
> static content and can't be place under /WEB-INF.  Since my applet is
> running now, and so think the docs could be wrong or haven't covered this
> topic completely. I hope someone could look this up.
>
> Anyway, thanks very much for your email again.  You have saved me!
>[...]





Thanks for your thanking!  :-)

BTW, there are two kinds of class/jar in a webapp:
  - for Servlet/jsp(it works in server-side)
  - for Applet or other static content(it will be downloaded to
    client together with Applet class, and works in client-side)

I think the reference email means:
   - class/jar for Servlet/jsp itself should be put under WEB-INF
   - class/jar for static content should Not be put under WEB-INF

I think your JDBC driver is used by your JSP directly, it works in
server-side, (it is not downloaded together with  your Applat and
work in client-side), so now, as you say, your JDBC driver should
be put in WEB-INF/lib.


Bo
Nov19, 2001



> >
> > reference email :-)
> > ------------------------------------------------------------------------
> > > In which directory of the Tomcat installation do we copy the html and
> > > applet classes?
> >
> > I suggest you also read the Application Developer's Guide included with
> > Tomcat.  The Tomcat 4 version is also online at:
> >
> >   http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/
> >
> > From the point of view of the server, applet classes and JAR files are
> > just static content.  Therefore, they should be placed in the same
> > directory as your static HTML pages, ***not*** under /WEB-INF.
> >
> > > Amit Lonkar
> > >
> >
> > Craig McClanahan
> > ------------------------------------------------------------------------
> >
> >
> >
> > Bo
> > Nov.18, 2001
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Yiu Wing" <yi...@yahoo.com>
> > To: <to...@jakarta.apache.org>
> > Sent: Monday, November 19, 2001 12:41 AM
> > Subject: [repost] loading class files
> >
> >
> > > Sorry guys this is a repost. But after doing numerous google search
and
> > > wading through the docs, I still can't solve my problem with regard to
> > > loading applet classes. I sincerely hope some of you can help me this
> > time,
> > > I desperately need to get this working.  The same message is as
follow.
> > >
> > > Hello All,
> > >
> > > I'm writing an applet that uses JDBC to connect to MySQL server , and
> the
> > > applet is embedded in a jsp.  I'm new to this, so I went on and read
the
> > > docs that come with Tomcat.  I'm also using CVS and ant for the
> > development.
> > > The source code layout of my project is as suggested in the docs,
which
> is
> > >
> > > project name
> > >                   |----- docs
> > >                   |----- src
> > >                   |----- web
> > >                                 |------>WEB-INF
> > >
> > > In the project/web/WEB-INF directory, do I have to create a classes
and
> > lib
> > > subdirectories?  The reason I ask this is because the class loader,
from
> > the
> > > Tomcat or web browser, can't find the class files.  But they're
clearly
> in
> > > the web directory, whose structure is as,
> > >
> > > project
> > >           |---- login.jsp (that's the jsp file that embeds the applet)
> > >           |---- WEB-INF
> > >                                 |------- classes (this directory has
all
> > the
> > > needed class files)
> > >                                 |------- lib (where the MySQL driver
is
> > > stored)
> > >
> > > The Tomcat docs says the classes and lib dir "are made visible to
other
> > > classes within your particular web application", but why my class
files
> > > can't be loaded there?  If I move all the class files to the top of
the
> > web
> > > directory, and change "code="MyClass.class""  to "code="MyClass"" in
the
> > jsp
> > > file, then everything seems to working OK. Oh, yeah, almost forgot, I
> also
> > > need to copy the whole directory tree for the driver to the web
> directory
> > as
> > > well.  Setting the classpath for the driver doesn't work.  I don't
want
> to
> > > copy the class files to the top of the web directory every time, can
> those
> > > file be loaded in the classes and lib directories.  Sorry about this
> > rather
> > > long message, but I'm getting very frustrated and hopping some of you
> can
> > > help me with this.
> > >
> > > Thanks for your help in advance.
> > >
> > > P.S. I'm using Tomcat4.0 on Win2000
> > >
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe:   <ma...@jakarta.apache.org>
> > > For additional commands: <ma...@jakarta.apache.org>
> > > Troubles with the list: <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
>
>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: [repost] loading class files

Posted by Yiu Wing <yi...@yahoo.com>.
> I suggest you put YourApplet.class together with your
> html/image or other "static contents), for ex. :
> webapps/yourapp0/staticContent/
> ("staticContent" is a folder made by you)

Thanks very much for your reply and reference email. Yeah, I have to create
an extra directory to store all my class files, and I also have to unzipped
the JDBC driver in order to get my jsp applet running. But from one of the
Tomcat's docs, which is tomcat-docs\appdev\deployment.html, in its mid page
says,

/WEB-INF/lib/ - This directory contains JAR files that contain Java class
files (and associated resources) required for your application, such as
third party class libraries or JDBC drivers.

I've copied my JDBC driver there, but it just won't work.  My citation is
just the opposite of your reference email, which says that JAR files are
static content and can't be place under /WEB-INF.  Since my applet is
running now, and so think the docs could be wrong or haven't covered this
topic completely. I hope someone could look this up.

Anyway, thanks very much for your email again.  You have saved me!

>
> reference email :-)
> ------------------------------------------------------------------------
> > In which directory of the Tomcat installation do we copy the html and
> > applet classes?
>
> I suggest you also read the Application Developer's Guide included with
> Tomcat.  The Tomcat 4 version is also online at:
>
>   http://jakarta.apache.org/tomcat/tomcat-4.0-doc/appdev/
>
> From the point of view of the server, applet classes and JAR files are
> just static content.  Therefore, they should be placed in the same
> directory as your static HTML pages, ***not*** under /WEB-INF.
>
> > Amit Lonkar
> >
>
> Craig McClanahan
> ------------------------------------------------------------------------
>
>
>
> Bo
> Nov.18, 2001
>
>
>
>
> ----- Original Message -----
> From: "Yiu Wing" <yi...@yahoo.com>
> To: <to...@jakarta.apache.org>
> Sent: Monday, November 19, 2001 12:41 AM
> Subject: [repost] loading class files
>
>
> > Sorry guys this is a repost. But after doing numerous google search and
> > wading through the docs, I still can't solve my problem with regard to
> > loading applet classes. I sincerely hope some of you can help me this
> time,
> > I desperately need to get this working.  The same message is as follow.
> >
> > Hello All,
> >
> > I'm writing an applet that uses JDBC to connect to MySQL server , and
the
> > applet is embedded in a jsp.  I'm new to this, so I went on and read the
> > docs that come with Tomcat.  I'm also using CVS and ant for the
> development.
> > The source code layout of my project is as suggested in the docs, which
is
> >
> > project name
> >                   |----- docs
> >                   |----- src
> >                   |----- web
> >                                 |------>WEB-INF
> >
> > In the project/web/WEB-INF directory, do I have to create a classes and
> lib
> > subdirectories?  The reason I ask this is because the class loader, from
> the
> > Tomcat or web browser, can't find the class files.  But they're clearly
in
> > the web directory, whose structure is as,
> >
> > project
> >           |---- login.jsp (that's the jsp file that embeds the applet)
> >           |---- WEB-INF
> >                                 |------- classes (this directory has all
> the
> > needed class files)
> >                                 |------- lib (where the MySQL driver is
> > stored)
> >
> > The Tomcat docs says the classes and lib dir "are made visible to other
> > classes within your particular web application", but why my class files
> > can't be loaded there?  If I move all the class files to the top of the
> web
> > directory, and change "code="MyClass.class""  to "code="MyClass"" in the
> jsp
> > file, then everything seems to working OK. Oh, yeah, almost forgot, I
also
> > need to copy the whole directory tree for the driver to the web
directory
> as
> > well.  Setting the classpath for the driver doesn't work.  I don't want
to
> > copy the class files to the top of the web directory every time, can
those
> > file be loaded in the classes and lib directories.  Sorry about this
> rather
> > long message, but I'm getting very frustrated and hopping some of you
can
> > help me with this.
> >
> > Thanks for your help in advance.
> >
> > P.S. I'm using Tomcat4.0 on Win2000
> >
> >
> >
> >
> >
> > --
> > To unsubscribe:   <ma...@jakarta.apache.org>
> > For additional commands: <ma...@jakarta.apache.org>
> > Troubles with the list: <ma...@jakarta.apache.org>
> >
> >
>
>
>
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>