• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help needed on HFSJ - Attributes and Listeners example

 
K Bala
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to do the Listener example in the HFSJ Chap 5 between pages 171-176.

I have created all the 3 .java files mentioned in pages 171-173.

All of them are in C:\proj\listenerTest\src\com\example folder.

I compiled the Dog class and the .class file is in the same folder as the source file. I get error when I try to compile the MyServletContextListener and ListenerTester classes.

The compiler says

java11:cannot resolve symbol
symbol: class Dog
location: class com.example.MyServletContextListener
Dog d = new Dog(dogBreed);

What am i doing wrong? Can someone pls. help?
[ December 12, 2005: Message edited by: K Bala ]
 
Patrick Williams
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have my book on me, but the Dog class has to be in the WEB-INF/classes directory of your test web app. If you've put a package statement in your Dog class, it needs to be in <apache home>/webapps/<web app name>/WEB-INF/classes/<package>. I hope that this helps.
 
K Bala
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for responding, Patrick.

I know that I should have a copy of my .class files in the WEB-INF/classes folder in the deployment directory. But my problem was that the source files did not compile.

I went ahead and compiled the 2 .java files in my IDE and they compiled fine. I don't know why I had trouble doing the same from the command prompt.

My servlets work fine and I got the desired output as well.
 
Chidanand Chauhan
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess class declartion problem. Please check the Access Specifier for the Dog class.If not resolved then
please send me the source code. right now i dont have the book.
 
Martyn Clark
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi make sure the top level directory is in your classpath if it is not you will get the error you discribed. This explains why you can compile in your IDE.
 
K Bala
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martyn. I set my classpath right.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic