• Post Reply Bookmark Topic Watch Topic
  • New Topic

form action and url pattern  RSS feed

 
Mike Gerd
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a simple JSP in which I try to call a servlet using the servlet's URL pattern but I get an HTTP 404 error. Im wondering are we allowed to call a servlet using its url pattern with a form action element in a JSP??

Below is the JSP code that calls the servlet.

<FORM name="form" action="/control" method="GET">

And, Below is the web.xml


Any suggestions?
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<FORM name="form" action="/control" method="GET">


Change this to



The action will now be considered relative to the context of the application. Earlier because of the '/' the action was NOT considered to be relative to the context of the application in which the jsp and servlet are deployed.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must specify both the context path and the path to the servlet. If the context path of the web app is /xyz, it must be specified in the action value:


[ July 14, 2007: Message edited by: Bear Bibeault ]
 
Mike Gerd
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks both
 
Satya Maheshwari
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just curious.What finally worked for you.
 
Mike Gerd
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first answer's answer.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whie you may have it working, bear in mind that page-relative addressing in web apps is fragile and not robust.
 
Jaikiran Pai
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Whie you may have it working, bear in mind that page-relative addressing in web apps is fragile and not robust.


I agree. The solution posted by Bear is the better of the two.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!