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


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Import class not working for Servlet" Watch "Import class not working for Servlet" New topic
Author

Import class not working for Servlet

Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
I am trying to get my first import to work in Tomcat 5.5 container but it is giving me error.

Here is my Controller:


Here is my bean file:


My JSP called Third.jsp:


I mapped in the web.xml so it should show on the web as:
http://127.0.0.1:8080/test/First

My error:

java.lang.NoClassDefFoundError: First (wrong name: beans/First)



My First.java is located in Tomcat 5.5 Home\webapps\test\WEB-INF\classes and the bean is located in Tomcat 5.5 Home\webapps\test\WEB-INF\classes\beans. My jsp is located in C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\test


Please advise.
[ July 23, 2006: Message edited by: Mike Jenkins ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Your import is not valid. You cannot import a package, you must import classes.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
Please advise how I do that?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Same way as for Java classes.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You need to either list each class explicitly:


or, to import all beans in a package, you can use the wildcard (*):


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Mike Jenkins
Ranch Hand

Joined: Jul 23, 2006
Posts: 57
Thanks to both of you.
It now works.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Import class not working for Servlet
 
Similar Threads
getting error while running servlet in tomcat
Tomcat 404 error
servlet not reloading on Tomcat 4.0
Servlet delivery in Tomcat
Configuring JNDI for JavaBean in Tomcat 5