Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbee, struts proj is not working

 
aditya rd
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am reading the Jakarta Struts live pdf, and learnt the basics of struts. I am trying to do the steps stated in the book. However, I am facing some issues. Can anyone please help me fix the problem..

Here are the details of the application:

--------------------------------------------------------------
My action:

package pkg.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


public class UserRegistrationAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
return mapping.findForward("success");
}

}


-----------------------------------------------

my jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User Registration Was Successful!</title>
</head>
<body>


<h1>Prayas, User Registration Was Successful!</h1>
</body>
</html>


---------------------------------------------------------

When I run the project after deploying the war on tomcat, i get 404 error
I tried with:
http://localhost:8080/TestStruts/pkg/action/userRegistration
http://localhost:8080/TestStruts/userRegistration
http://localhost:8080/TestStruts/

all 3 cases fail. Please help me. I have attached struts-config, web.xml and dir structure of my proj
web.GIF
[Thumbnail for web.GIF]
web
dir-structure-of-project.GIF
[Thumbnail for dir-structure-of-project.GIF]
dir-structure
struts-config.GIF
[Thumbnail for struts-config.GIF]
struts-config
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that I haven't worked with struts in a while so some of the following may not be accurate. Some suggestions:
1. You will probably get more responses if you post text rather than images. For me, the images are too blurry when seen in my browser so I have to download them and it is harder to review images then simple text.
2. In your URLs, you are using the servlet display-name (TestStruts). I think you need to use the servlet-name (action).
3. In your url-pattern, you use *.do but no part of your URL specifies ".do"
4. I think your errors have nothing to do with struts but with your understanding of servlets. Try creating a HelloWorld servlet first. Once you get that running and understand the details, progress to creating a servlet that uses struts.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic