You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Paul Foxton <pa...@network-sol.com> on 2001/08/06 16:53:49 UTC

RE: Servlet Uses Another Class

did you import the class explicitly in your servlet?

eg: (without a package)

import MyClass;

public class MyServlet extends HttpServlet throws ServletEsception
IOException
  {
    MyClass instanceOfMyClass;
    instanceOfMyClass = new MyClass();

    etc.

to import the class in the package:

import com.mypackage.MyClass

cheers,

Paul

> -----Original Message-----
> From: A.L. [mailto:amoslieber@yahoo.com]
> Sent: 06 August 2001 16:04
> To: tomcat-user@jakarta.apache.org
> Subject: Servlet Uses Another Class
> 
> 
> I am unable to create and run a servlet which uses
> another class which I have create.  How may this be
> achieved.
> 
> Here is my problem:
> I have a servlet (myServlet), which needs to create an
> instance of a class I designed.  I assumed that
> putting the myClass.class file in the WEB-INF/classes/
> directory along with the myServlet.class file would
> take care of this. Yet I get a "cannot resolve symbol
> error".  
> My next idea was to put the class file in a directory
> titled myPackage.  In the myServlet class I put the
> proper import myPackage.*; and in the myClass.class
> file I put the code package myPackage.
> 
> I assumed that perhaps turning the class file into a
> package would help.  But now I get an error stating:
> package myPackage does not exist.
> 
> 
> My question is how can I get the servlet to find the
> class I created so that it may create an instance of
> the class?
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make international calls for as low as $.04/minute with 
> Yahoo! Messenger
> http://phonecard.yahoo.com/
> 

RE: Servlet Uses Another Class

Posted by "A.L." <am...@yahoo.com>.
I have tried simply importing the class MyClass, and
not creating it as a package.  Nevertheless I get the
Cannot Resolve Symbol error.

Both the MyClass and the MyServlet class files are in
the same directory.  In my servlet 
--- Paul Foxton <pa...@network-sol.com> wrote:
> did you import the class explicitly in your servlet?
> 
> eg: (without a package)
> 
> import MyClass;
> 
> public class MyServlet extends HttpServlet throws
> ServletEsception
> IOException
>   {
>     MyClass instanceOfMyClass;
>     instanceOfMyClass = new MyClass();
> 
>     etc.
> 
> to import the class in the package:
> 
> import com.mypackage.MyClass
> 
> cheers,
> 
> Paul
> 
> > -----Original Message-----
> > From: A.L. [mailto:amoslieber@yahoo.com]
> > Sent: 06 August 2001 16:04
> > To: tomcat-user@jakarta.apache.org
> > Subject: Servlet Uses Another Class
> > 
> > 
> > I am unable to create and run a servlet which uses
> > another class which I have create.  How may this
> be
> > achieved.
> > 
> > Here is my problem:
> > I have a servlet (myServlet), which needs to
> create an
> > instance of a class I designed.  I assumed that
> > putting the myClass.class file in the
> WEB-INF/classes/
> > directory along with the myServlet.class file
> would
> > take care of this. Yet I get a "cannot resolve
> symbol
> > error".  
> > My next idea was to put the class file in a
> directory
> > titled myPackage.  In the myServlet class I put
> the
> > proper import myPackage.*; and in the
> myClass.class
> > file I put the code package myPackage.
> > 
> > I assumed that perhaps turning the class file into
> a
> > package would help.  But now I get an error
> stating:
> > package myPackage does not exist.
> > 
> > 
> > My question is how can I get the servlet to find
> the
> > class I created so that it may create an instance
> of
> > the class?
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with 
> > Yahoo! Messenger
> > http://phonecard.yahoo.com/
> > 


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/