got stuck with my first struts example

S

sonali

Hi
I tried running my first struts example but got stuck with the HTTP 404 error.
description:The requested resource (/actions/register1.do) is not available. I am using tomcat 4.1.29 and struts 1.1.
I kept struts.jar in my classpath. Struts.jar is also present in the lib dir of my web appl.
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 kept the java class under classes/coreservlets dir. I used the web.xml file which comes under struts-blank.war and made no changes to it.
What went wrong? Please let me know.
 
S

Sudsy

sonali said:
Hi
I tried running my first struts example but got stuck with the HTTP 404 error.
description:The requested resource (/actions/register1.do) is not available. I am using tomcat 4.1.29 and struts 1.1.

So where's your web.xml? In particular the servlet-mapping element
which maps *.do to your application? You know, in the url-pattern
element...
 
R

Ryan Stewart

available. I am using tomcat 4.1.29 and struts 1.1.
So where's your web.xml? In particular the servlet-mapping element
which maps *.do to your application? You know, in the url-pattern
element...
If you read all the way to the bottom, he/she says he/she used the web.xml
from the struts-blank app and made no changes. The correct mapping is there.
To OP: Are you sure you've got your paths right? In your html form, your
action is "../actions/register1.do". Are you sure that's pointing at the
right place? Did you restart your server after you got everything in place?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top