aspose file tools*
The moose likes Servlets and the fly likes Trouble with controller servlet mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Trouble with controller servlet mapping" Watch "Trouble with controller servlet mapping" New topic
Author

Trouble with controller servlet mapping

Dave Thomas
Ranch Hand

Joined: Nov 05, 2001
Posts: 30
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

Joined: Jan 08, 2001
Posts: 2164
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

Joined: Nov 24, 2000
Posts: 776
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

Joined: Nov 05, 2001
Posts: 30
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

Joined: Nov 05, 2001
Posts: 30
OK. I've worked it out. The action needed to be:
action="\<appNmae>\login".
Thanks again.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Trouble with controller servlet mapping
 
Similar Threads
Loading two servlets at the startup?
load on startup problem
What's wrong with my deployment descriptor?
Startup of servlets/ JVM:s
help with module level struts config