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

figuring out servlets?

 
Tom Boyce
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I constantly have problems pointing to a servlet from a jsp, so I know I'm missing something fundamental. Can someone help me understand? Here is my directory structure:
webapps
FamilyViolence
WebApplication1
build
generated
web
images
jsp
Shelter_CheckIn.jsp
META-INF
WEB-INF
classes
FamilyViolence
bus
ValidateChildren.class
src
FamilyViolence
ValidateChildren.java

I want to go from my Shelter_CheckIn.jsp to the ValidateChildren.Class

Here is my web.xml

<servlet-name>ValidateChildren</servlet-name>
<servlet-class>FamilyViolence.bus.ValidateChildren</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ValidateChildren</servlet-name>
<url-pattern>/servlet/ValidateChildren</url-pattern>
</servlet-mapping>

And finally, how I'm attempting to get there in my jsp

<form name="intake" action="/ValidateChildren">

If anyone can help me not only fix the problem, but understand I would be greatly appreciative!

Thanks!
 
Sheldon Fernandes
Ranch Hand
Posts: 157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Match the form's action to the servlet's URL pattern.
<form name="intake" action="/servlet/ValidateChildren">

In order to invoke your servlet, the URL used must match the </url-pattern> defined in the </servlet-mapping>. All requests matching the URL pattern provided will be sent to the servlet.

Sheldon
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic