• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble with controller servlet mapping

 
Dave Thomas
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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.
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • 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
 
Guy Allard
Ranch Hand
Posts: 776
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
OK. I've worked it out. The action needed to be:
action="\<appNmae>\login".
Thanks again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic