wood burning stoves 2.0*
The moose likes Servlets and the fly likes Java Beans and Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Java Beans and Servlet" Watch "Java Beans and Servlet" New topic
Author

Java Beans and Servlet

Amtul Schwab,
Greenhorn

Joined: Dec 07, 2004
Posts: 10
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

Joined: Nov 28, 2001
Posts: 233
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


Sharing is learning
Amtul Schwab,
Greenhorn

Joined: Dec 07, 2004
Posts: 10
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

Joined: Nov 28, 2001
Posts: 233
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

Joined: Dec 07, 2004
Posts: 10
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

Joined: Dec 07, 2004
Posts: 10
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

Joined: Nov 28, 2001
Posts: 233
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Beans and Servlet
 
Similar Threads
Servlet cannot access bean/Servlet Not found
Creating a class within JSP to be shared among pages
getting beans to see each other
Problem running jsps in Weblogic
Tomcat Restarting