Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

servlet doesn't work with package declaration in java file

Status
Not open for further replies.

BXLman

Programmer
Jul 5, 2006
2
0
0
BE
I have a problem with my first servlet in tomcat.
It works fine when i have no "package declaration" in my code.

But when i write this at the top of my code, it doesn't work anymore:

package sk.tomcatuser.svlt;



The class that contains the servlet code is called "Rot31"

public class Rot13 extends HttpServlet { ....



I've added this in the web.xml, but appearently it seems not to work anymore.

<servlet>
<servlet-name>Rot13</servlet-name>
<servlet-class>sk.tomcatuser31.svlt.Rot13</servlet-class>
</servlet>

and

<servlet-mapping>
<servlet-name>Rot13</servlet-name>
<url-pattern>/servlet/Rot13</url-pattern>
</servlet-mapping>



when i leave out the package-things, it works :-(
what's wrong and where ?
 
ok got it.
i have to put the class file in a subdirectory structure of WEB-INF, like declared in the package.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top