This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Struts and the fly likes Problem with my first struts application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem with my first struts application" Watch "Problem with my first struts application" New topic

Problem with my first struts application

kiran india

Joined: Jan 09, 2008
Posts: 2
Hi, all. Iam new to struts. As a part of starting my journey towards struts, I started with a simple struts application. But I am facing problem with either actionForm or actionClass or someother. Here is entire application. Please go through this and help me.

My application location : C:\Tomcat 5.5\webapps\myStruts (In this, My application name is myStruts.)
Contents of myStruts folder : WEB-INF folder, First.jsp, Second.jsp.

C:\Tomcat 5.5\webapps\myStruts\First.jsp code
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:form action="/">
<html:errors />
<td>Enter Your Nick Name: </td>
<td><input type="text" name="nick" /></td>
<td>Enter Your Lucky Number: </td>
<td><input type="text" name="lucky" /></td>
<td align="right"><input type="submit" value="Submit" /></td>

C:\Tomcat 5.5\webapps\myStruts\Second.jsp code
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>

<html:errors />
<p><h2>Hai, you are redirected from First.jsp</h2></p>

Contents of myStruts/WEB-INF folder :
actionForms folder (contains, FirstActionForm.class),
actions folder (contains, FirstAction.class),
classes (empty) folder,
lib (containing jar files) folder, and
xml files (struts-config, web, tiles-defs, validation, validator-rules).

C:\Tomcat 5.5\webapps\myStruts\WEB-INF\actions\ code
import javax.servlet.http.*;
//import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.*;
//import org.apache.struts.action.ActionForm;
//import org.apache.struts.action.ActionForward;
//import org.apache.struts.action.ActionMapping;

public class FirstAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("This is from Action class");
return mapping.findForward("success");

C:\Tomcat 5.5\webapps\myStruts\WEB-INF\actionForms\ code
import org.apache.struts.action.*;
import javax.servlet.http.HttpServletRequest;

public class FirstActionForm extends ActionForm{

private String nick = null;
private String lucky = null;

public String getNick() {
return nick;

public String getLucky() {
return lucky;

public void setNick(String nick) {
this.nick = nick;

public void setLucky(String lucky) {
this.lucky = lucky;

public void reset(ActionMapping mapping, HttpServletRequest request) {


C:\Tomcat 5.5\webapps\myStruts\WEB-INF\web.xml code
<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

<display-name>Struts Blank Application</display-name>

<!-- Standard Action Servlet Configuration (with debugging) -->

<!-- Standard Action Servlet Mapping -->

<!-- Struts Tag Library Descriptors -->






C:\Tomcat 5.5\webapps\myStruts\WEB-INF\struts-config.xml code
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"

<data-sources> </data-sources>

type="actionForms.FirstActionForm" />

<global-exceptions> </global-exceptions>
<global-forwards> </global-forwards>


validate ="false">
<forward name="success" path="/Second.jsp"/>


<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="moduleAware" value="true" />
<set-property property="definitions-parser-validate" value="true" />

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>


<---Please give me necessary suggestions in my Journey towards Struts--->
I hope this journey with you will leave me and you so much of knowledge.
Thank you.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32844

Please don't post the same question in multiple threads. I'll close this one for you.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Problem with my first struts application
It's not a secret anymore!