• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Servlet URL Pattern problem

 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my web.xml i have the following url-pattern for a servlet:
<url-pattern>/login</url-pattern>

and in the login.jsp
<form method="post" action="/login">

but when i submit the form, a 404 error is thrown. then i changed the above form action to
<form method="POST" action="login">
(notice the absence of the / before "login")

and it worked.

my question is, why did the server throw an 404 error even though the url pattern matched. does the server automatically add '/' before the "action" in the form tag?

thanks in advance,
Seshu
 
Kai Witte
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

this has nothing to do with servlets. HTML 4.01 Transitional uses the URI syntax as described in RFC 2396 for the action attribute in the form tag. The thing you used first ("/login") is called an "absolute-path reference" there, and it means that the absolute URI you requested is the netpath/login. But what you really wanted is netpath/your-application/login.

The way it worked for you is ok, too. That's a "relative-path reference" ("login").

So the options are something like:
action="http://localhost:8080/hf/login"
action="/hf/login"
action="login"

http://www.ietf.org/rfc/rfc2396.txt

Conan
 
Sree Jag
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Conan, thanks for the reply. that was really informative.

Seshu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic