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

how to arrange package in WEB-INF

 
Ian Yang
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This should be like this:
http://127.0.0.1/servlet/thisServlet
/Rene
[ July 03, 2002: Message edited by: Rene Larsen ]
 
Garann Means
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic