File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Import class not working for Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply 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: 56179
    
  13

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: 56179
    
  13

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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Import class not working for Servlet
 
Similar Threads
Tomcat 404 error
Servlet delivery in Tomcat
servlet not reloading on Tomcat 4.0
getting error while running servlet in tomcat
Configuring JNDI for JavaBean in Tomcat 5