GeeCON Prague 2014*
The moose likes Struts and the fly likes problems with action mapping Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problems with action mapping" Watch "problems with action mapping" New topic
Author

problems with action mapping

meka toka
Ranch Hand

Joined: Dec 11, 2002
Posts: 75
Hi,
I am new to Struts, i am facing the following a problem with the action mappings.
Here are my code snippets
In web.xml
------------
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
In login.jsp
-------------
<html:form action="/Login"
name="LoginForm"
type="com.xxx.yyy.LoginForm" >

In struts-config.xml
---------------------
FORM-BEANS
------------
<form-beans>
<form-bean name="LoginForm" type="com.xxx.yyy.LoginForm"/>
</form-beans>
GLOBAL FORWARDING
------------------
<global-forwards>
<forward name="Login" path="/login.jsp"/>
</global-forwards>
ACTION MAPINGS
----------------
<action-mappings>
<action path="/Login" type="com.xxx.yyy.LoginAction" scope="request" input="/login.jsp" name="LoginForm">
<forward name="Success" path="/welcome.jsp"/>
<forward name="Failure" path="/login.jsp"/>
</action>

With the above code, when the login.jsp is submitted the values have to be filled in LoginForm which is an ActionForm for the ActionClass LoginAction .
The associated action path is supposed to be /Login but when the jsp is submitted i get an error page saying
The requested resource (/MyApp/Login.do) is not available.
Can somebody point me where am i wrong ?
I am using Tomcat 4.1.24, Struts 1.1
TIA
Meka Toka


Thanks<br />MekaToka<br />SCJP 1.4
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4474
    
    6

Did you define the servlet in web.xml as well?
See the <servlet> definition in the example at http://www.reumann.net/do/struts/lesson1/step7
meka toka
Ranch Hand

Joined: Dec 11, 2002
Posts: 75
Yes i have defined the ActionServlet in the web.xml, the reason why i didnt provide the code snippet earlier is because i was trying to show all the code related to the action mapping in both the deployment descriptors.
This looks like a problem that many beginners face, i searched but found no solution.
Any more suggestions ?
TIA
Meka Toka
[ July 24, 2003: Message edited by: meka toka ]
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4474
    
    6

I vaguely remember this happening to me a while back. I'll have to get back to you later though...In the meantime, try searching this site and the web for that error message; use a search phrase like "Tomcat Struts resource not available"
meka toka
Ranch Hand

Joined: Dec 11, 2002
Posts: 75
Also can somebody clarify this
When a struts application is deployed on Tomcat server, should there be any pop ups of the Action Mapping, Success and Failure files.
If the pop up doesnt come up in stack trace when starting Tomcat, does it mean that the form-beans(ActionForms) are not properly configured in deployment descriptors ?
Does extending the ActionMapping and writing your own ActionMapping cause any of these pop ups ?
I am asking this because, when i start Tomcat no popups comeup, where as when i place storefront sample application, there are pop ups of the Form beans, and some other stuff.
Thank You
Meka Toka
Sazzad Rafique
Greenhorn

Joined: Jul 29, 2003
Posts: 5
Hi,
I guess the problem is in the jsp page from where you click on the link to invoke the action. I got the same error when I was using <a href=""></a> instead of <html:link></html:link>. My mistake was I was using an extra "/". So if you check the address in the task bar when you put your mouse on the link of that action you might get a clue.
 
GeeCON Prague 2014
 
subject: problems with action mapping