This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to arrange package in WEB-INF 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 "how to arrange package in WEB-INF" Watch "how to arrange package in WEB-INF" New topic
Author

how to arrange package in WEB-INF

Ian Yang
Ranch Hand

Joined: Nov 27, 2001
Posts: 44
Hi,
I have a question about using package for servlets. Suppose I have the following package structure:
Inside the application directory my-app/, I want to put a java class myServlet.class which belongs to the package my-pack/, so I create the following structure:
my-app/my.jsp
my-app/WEB-INF/classes/my-pack/myServlet.class
my-app/WEB-INF/web.xml
What this is doing is to go from "my.jsp" and then click a SUBMIT button to go to "myServlet" page. But, the interesting thing I noticed is -- If I do NOT define "myServlet" in the <servlet> part of web.xml, it works fine. However, if I defined it, it failed. I tried the follwoing two ways to define the <servlet-calss> for "myServlet"
a) <servlet-class> myServlet </servlet-class>
b) <servlet-class> my-pack.myServlet </servlet-class>
but none of them works. So, question is -- if we have packaged servlet, do we need to define them in the web.xml and how to reflect their package structure in the <servlet-class> part ?
Thank,
Ian
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179


This should be like this:
http://127.0.0.1/servlet/thisServlet
/Rene
[ July 03, 2002: Message edited by: Rene Larsen ]

Regards, Rene Larsen
Dropbox Invite
Garann Means
Ranch Hand

Joined: Jan 28, 2002
Posts: 214
Ian,
You should be able to do this:

Then call your servlet like "form.action = 'myServlet';". It may be overkill, but I'm 99.9% sure it'll work.
HTH,
g.
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Ian,
Then call your servlet like "form.action = 'myServlet';". It may be overkill, but I'm 99.9% sure it'll work.


The form should be like this:
'form.action="/myServlet";'
/Rene
[ July 04, 2002: Message edited by: Rene Larsen ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to arrange package in WEB-INF
 
Similar Threads
jsp:include page="header.html" causes IllegalStateException
HelloWorldServlet in Weblogic 6.0
tomcat newbie
Tomcat upgrade now servlets unavailable
Error 500: Failed to load target servlet