This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Servlet URL Pattern problem  RSS feed

 
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
 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!