• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

got stuck in running my first struts example. help

 
sonali rao
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic