• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Trouble with controller servlet mapping

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to get a controller pattern happening using servlet mapping but am having a little trouble. Heres an excerpt of my web.xml:
<web-app>
<servlet>
<servlet-name>maincontroller</servlet-name>
<servlet-class>ControllerServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>maincontroller</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<web-app>
This line in my jsp file:
<form action="login" method="POST">
returns a 404 error. Resource not found.
Why do you suppose this is.
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Caveman Thomas:

<form action="login" method="POST">


Try action="/login"
Am not testing it, but as far as I remember without / syntax results in relative link from the document you are in. So if your jsp is in caveAppRoot/jsp/ directory it searches there for the servlet.

With /login the link is relative to context root. So it should find the servlet indicated in the dd.
Axel
 
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
CT - See my last post in the other discussion.
If you still have web.xml in:
TOMCAT_HOME/appname, then startup is not reading it!!
It needs to be in:
TOMCAT_HOME/appname/WEB-INF
Regards, Guy
Just out of curiosity, what is your delta off of GMT?
[ March 14, 2002: Message edited by: Guy Allard ]
 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Guy. I actually do have the web.xml file under WEB-INF and everything seems to be cool in that department. Beans, servlets and jsps are working fine. (Not sure what the delta off GMT is but I can tell you that right now its too late to work it out. Its 2am here now.)
Still am having a problem with the mapping though. You are right Axel. The action does need a "/" in front but now I have a different message. ie: HTTP Status 503 - Servlet maincontroller is currently unavailable.
I have the ControllerServlet in the classes dir.
[ March 14, 2002: Message edited by: Caveman Thomas ]
 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. I've worked it out. The action needed to be:
action="\<appNmae>\login".
Thanks again.
 
I knew that guy would be trouble! Thanks tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic