Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java Beans and Servlet

 
Amtul Schwab,
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys...
i m making a simple application which consists of a bean,servlet and jsp.
i have make bean objects in servlet class and my first jsp calls that servlet just to initiate the servlet then the servlet will make beans and forward htem to another jsp.Thats all abt it.
Now the problem is that when i tries to compile servlet it fails and he error says that "can not resolve symbol" ...on MyBean.
this means servlet cant find the bean class.
I have make a test folder in c drive and he hierarchy is as follows:
C:\test\WEB-INF\classes\test\
in this test folder in classes folder i have placed
MyServlet.java and MyBean.java and MyBean.class

I dont know wat the problem is..
plz help me asap..
thanx
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
By the information you have provide I feel problem would be in setting the classpath.
Make sure you have set the root folder (C:\test\WEB-INF\classes\test\) where the class file are created is in the classpath.
Hope this tip help you.
-Arun
 
Amtul Schwab,
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Arun...
now i have changed the over all class' layout..
I have put servlet in
Tomcat 4\webpapps\examples\web-inf\classes\MyServlet.java
and the bean iin
Tomcat 4\webpapps\examples\web-inf\classes\Bean\MyBean.class and MyBean.java both are here.

no other changes in classpath..i think tomcat 4 sets its classpath by default so nothing added in autoexec.bat by me.

Still i am getting same error..
plz help..
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At compile time it is important that the mode(command line or some IDE) in which you are compiling have the relevent classpath set. Ofcouse your webserver (tomcat in your case)would look for this path when it is excuting your compiled source code.
-Arun
 
Amtul Schwab,
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmm no solution till yet!
Arun i am not getting u..pls elaborate ur answer..
and also tell me where my bean gone?
although it is in packcge but why servlet does not get it?
 
Amtul Schwab,
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok thanx Arun i got it solved..
but now i want to call the servlet from jsp..infact forward control to servlet but it says no servlet class found..i have kept jsp in jsp foleder while servlet n bean are in testbean packge.
pzl help
 
Arun Boraiah
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to register Servlet in deployment descriptor (webl.xml) for JSP to access the same. If you have not done it please do the same.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic