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

classes directory

 
Amber Woods
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using webappcabaret to learn servlets and I have created some servlets successfully when I place them directly under my context name in the directory WEB-INF/classes but when I try to put servlets in a directory under classes it won't work.
For example I created a TestServlet that just prints out a message and type this in the address bar: www.webappcabaret.com/amberw/servlet/Test.TestServlet. The error that I got was this:
Error: 500
Location: /amberw/servlet/Test.TestServlet
Internal Servlet Error:
java.lang.NoClassDefFoundError: Test/TestServlet (wrong name: TestServlet)
...plus a bunch more junk
I don't know what I am doing wrong. I am not sure if I need to put something in web.xml or not.
Any Help is appreciated
Thanks - Amber
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Amber:
From what I understand using hints from the terms Test.TestServlet, you have a package structure for your
TestServlet.
Hence you should not put your class file in the WEB-INF/classes
folder. You need to create a Test folder under classes and then
copy your TestServlet.class file into the newly created Test folder.
Correct me if I am wrong, meaning if you don't have a package structure in your TestServlet.
regds.
- satya
 
Amber Woods
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, Satya, I don't have TestServlet as part of a package but if that is the way to get it to work I will make it part of a package.
All I really want to do is be able to keep my class files separate and neat. I have two servlets with the same name but different contents (for an assignment). I just wanted to keep them separate (putting them in different folders under classes directory) instead of having to rewrite over the previous version any time I wanted to see if that servlet works correctly.
This is something like where my files are:
WEB-INF/classes/Test/TestServlet.class
WEB-INF/classes/Test2/TestServlet.class
and the TestServlet.class files are different. The way I called them in the location bar has been like this:
www.webappcabaret.com/amberw/servlet/Test.TestServlet www.webappcabaret.com/amberw/servlet/Test/TestServlet www.webappcabaret.com/amberw/servlet/TestServlet www.webappcabaret.com/amberw/servlet/Test2.TestServlet www.webappcabaret.com/amberw/servlet/Test2/TestServlet
and none of them work but maybe I will try to put them in a package. I just thought it would be something else.
Thanks - Amber
[This message has been edited by Amber Woods (edited June 26, 2001).]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic