OT: Basic understanding of web.xml

Hi,

I'm completely new to server-side development, so please excuse this
dumb question (we could not found a good answer, neither in our book nor
with google):

How does the webserver (concret Tomcat 4.0.x) resolves a form-action?

html-content: ... web.xml with and ]]> entries

Thanks in advance.

Tom

3 comments
Comment actions Permalink

You need to have a servlet that maps to login. Then the form will submit
to the servlet. Look at some of the examples jsps that come with tomcat.
One in particular is called jsp servelet jsp, that covers this. Look at
its web.xml

Thomas Singer wrote:

Hi,

I'm completely new to server-side development, so please excuse this
dumb question (we could not found a good answer, neither in our book nor
with google):

How does the webserver (concret Tomcat 4.0.x) resolves a form-action?

html-content: <form ... action="login">...
web.xml with <servlet> and <servlet-mapping> entries

Thanks in advance.

Tom


0
Comment actions Permalink

Thanks.

> Look at some of the examples jsps that come with tomcat.

Looks, like my coworker wiped the examples directory :)

Tom


Steven Citron-Pousty wrote:

You need to have a servlet that maps to login. Then the form will submit
to the servlet. Look at some of the examples jsps that come with tomcat.
One in particular is called jsp servelet jsp, that covers this. Look at
its web.xml


0
Comment actions Permalink

With the risk of stating some obvious things and leaving out some that
are not that obvious, here is a short three step explanation, where step
two should be the part you asked for.

1. The HTML form part
In the html form element there are two relevant attributes: action and
method. The action attribute value is a URL (possibly relative) that the
browser will use when calling the server. The method attribute value is
either GET (default) or POST. The browser either makes a HTTP GET
request or HTTP POST request when the form is submitted.

2. The web application servlet mapping part
When the HTTP request reaches the servlet engine the URL is matched
against the servlet-mapping entries in web.xml. The entries contain
patterns that can specify exact URL paths or partial paths that may
match more than one URL. There are rules for match priority that
basically mean that the most specific match will be used if more than
one pattern match.

3. Servlet invocation
Once a servlet-mapping pattern is selected the servlet mapped by the
mapping will be invoked. Depending on the HTTP request type (GET or
POST) the corresponding method (doGet(...) or doPost(...)) will be
called on the servlet, assuming it is a subclass of HttpServlet.

For a more thorough explanation I recommend the Servlet 2.3
specification, which is quite OK as far as specifications go.

I hope this helped in some way.

/Fredrik Lindgren

Thomas Singer wrote:

Thanks.

> Look at some of the examples jsps that come with tomcat.

Looks, like my coworker wiped the examples directory :)

Tom


Steven Citron-Pousty wrote:

>> You need to have a servlet that maps to login. Then the form will
>> submit to the servlet. Look at some of the examples jsps that come
>> with tomcat. One in particular is called jsp servelet jsp, that covers
>> this. Look at its web.xml



0

Please sign in to leave a comment.