aspose file tools*
The moose likes Struts and the fly likes got stuck in running my first struts example. help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "got stuck in running my first struts example. help" Watch "got stuck in running my first struts example. help" New topic
Author

got stuck in running my first struts example. help

sonali rao
Ranch Hand

Joined: Nov 03, 2003
Posts: 64
Hi
I tried to run my first struts application but did not succeed. I am getting the famous HTTP status 404 error. I am using tomcat 4.1.29 version and struts 1.1 for running this example.
error description: The requested resource (/actions/register1.do) is not available.
What went wrong? The following is the source code.
struts-config.xml
<struts-config>
<action-mappings>
<action path="/actions/register1"
type="coreservlets.RegisterAction1">
<forward name="success"
path="result1.jsp"/>
</action>
</action-mappings>
</struts-config>
register1.jsp
<HTML>
<HEAD><TITLE>New Account Registration</TITLE></HEAD>
<BODY BGCOLOR="#FDF5E6">
<CENTER>
<H1>New Account Registration</H1>
<FORM ACTION="../actions/register1.do" METHOD="POST">
Email address: <INPUT TYPE="TEXT" NAME="email"><BR>
Password: <INPUT TYPE="PASSWORD" NAME="password"><BR>
<INPUT TYPE="SUBMIT" VALUE="Sign Me Up!">
</FORM>
</CENTER>
</BODY></HTML>
RegisterAction1.java
package coreservlets;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class RegisterAction1 extends Action {
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
return(mapping.findForward("success"));
}
}
result1.jsp
<HTML>
<HEAD><TITLE>Success</TITLE></HEAD>
<BODY BGCOLOR="#FDF5E6">
<CENTER>
<H1>You have registered successfully.</H1>
(Version 1)
</CENTER>
</BODY></HTML>

I placed RegisterAction1.java file under classes/coreservlets directory.
[ March 02, 2004: Message edited by: sonali rao ]
Bruno Korcinski
Greenhorn

Joined: Jun 03, 2003
Posts: 16
Hi,
try check web.xml servlet mapping ....should be sopmething like
(check some example)
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*/*.do</url-pattern>
</servlet-mapping>
Igor
lee anthony
Ranch Hand

Joined: Jan 23, 2004
Posts: 35
i beleive u got the answer for ur question
but in addition to the same what struts is expecting from web.xml is
in form action do not give the whole path not a good practice instead give the /xx format pateer , which should match the /xx action in sturt config file
i beleive this will help u, for better coding
lee
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: got stuck in running my first struts example. help