Creating a new class instance from a servlet

Discussion in 'Java' started by Damo, Nov 15, 2006.

  1. Damo

    Damo Guest

    Hi,
    I have a servlet and and trying to instantiate a class in the servlet.
    I'm using the following code:
    engine e = new engine();
    The engine class compiles without error but when i compile the servlet
    i get 2 errors from this line cannot find symbol. Anyone know what the
    problem might be?
    Thanks
     
    Damo, Nov 15, 2006
    #1
    1. Advertising

  2. > The engine class compiles without error but when i compile the servlet
    > i get 2 errors from this line cannot find symbol. Anyone know what the
    > problem might be?


    Did you import the correct package? Is the class accessible to the
    servlet?

    -cheers,
    Manish
     
    Manish Pandit, Nov 15, 2006
    #2
    1. Advertising

  3. Damo

    Damo Guest

    the servlet is in the classes folder in a package called Search and the
    class i'm trying to instantiate is in Search.model , but it cant find
    it. i am importing the search.model folder
    thanks




    Manish Pandit wrote:
    > > The engine class compiles without error but when i compile the servlet
    > > i get 2 errors from this line cannot find symbol. Anyone know what the
    > > problem might be?

    >
    > Did you import the correct package? Is the class accessible to the
    > servlet?
    >
    > -cheers,
    > Manish
     
    Damo, Nov 15, 2006
    #3
  4. Damo

    Guest

    Damo wrote:
    > the servlet is in the classes folder in a package called Search and the
    > class i'm trying to instantiate is in Search.model , but it cant find
    > it. i am importing the search.model folder
    > thanks


    try this:

    Search.model.engine e = new Search.model.engine();

    and make sure Search.model.engine class is there in runtime CLASSPATH.
    hope it helps.
     
    , Nov 15, 2006
    #4
  5. Damo

    Guest

    This is a compile time, not a runtime error, right?


    -Cameron McKenzie
    Author of the SCJA Certification Guide and What is WebSphere?


    Certification Resources: www.examscam.com
    Free WebSphere Tutorials: www.pulpjava.com
    Free Mock Java Certification Exams: www.scja.com
    Free J2EE and Java Multimedia Tutorials: www.mcnz.com

    wrote:
    > Damo wrote:
    > > the servlet is in the classes folder in a package called Search and the
    > > class i'm trying to instantiate is in Search.model , but it cant find
    > > it. i am importing the search.model folder
    > > thanks

    >
    > try this:
    >
    > Search.model.engine e = new Search.model.engine();
    >
    > and make sure Search.model.engine class is there in runtime CLASSPATH.
    > hope it helps.
     
    , Nov 15, 2006
    #5
  6. Damo

    trippy Guest

    In article <>,
    Damo took the hamburger meat, threw it on the grill, and I said "Oh
    Wow"...

    > Hi,
    > I have a servlet and and trying to instantiate a class in the servlet.
    > I'm using the following code:
    > engine e = new engine();
    > The engine class compiles without error but when i compile the servlet
    > i get 2 errors from this line cannot find symbol. Anyone know what the
    > problem might be?


    Engine e = new Engine(); ?

    Just a guess, since you didn't post the error message.

    > Thanks


    --
    trippy
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "All I Really Want" -- Alanis Morissette

    "Now, technology's getting better all the time and that's fine,
    but most of the time all you need is a stick of gum, a pocketknife,
    and a smile."

    -- Robert Redford "Spy Game"
     
    trippy, Nov 16, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. circuit_breaker
    Replies:
    2
    Views:
    2,047
    Jack Jia
    Apr 4, 2004
  2. chamikara
    Replies:
    1
    Views:
    49,909
  3. Sridhar R
    Replies:
    14
    Views:
    1,425
    =?iso-8859-1?Q?Fran=E7ois?= Pinard
    Feb 10, 2004
  4. Martin P. Hellwig
    Replies:
    1
    Views:
    380
    Martin P. Hellwig
    Mar 26, 2010
  5. Olive
    Replies:
    4
    Views:
    250
    Olive
    Jul 6, 2012
Loading...

Share This Page