my action class:
-----------------------------------------------
package actions;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.validator.DynaValidatorForm;
import forms.sheduleForm;
/**
* @version 1.0
* @author
*/
public class shedule1Action extends Action {
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward(); // return value
// DynaValidatorForm dynaValidatorForm = (DynaValidatorForm) form;
try {
// do something here
System.out.println("step2");
sheduleForm project = new sheduleForm();
project.setProjectName("sheduling testssss");
} catch (Exception e) {
// Report the error using the appropriate name and ID.
errors.add("name", new ActionError("id"));
}
// If a message is required, save the specified key(s)
// into the request for use by the <
struts:errors> tag.
if (!errors.isEmpty()) {
saveErrors(request, errors);
// Forward control to the appropriate 'failure' URI (change name as desired)
//forward = mapping.findForward("failure");
} else {
// Forward control to the appropriate 'success' URI (change name as desired)
// forward = mapping.findForward("success");
}
// Finish with
return (mapping.findForward("success"));
}
}
-----------------------------------------------------------
My form bean
-----------------------------------------------------------
package forms;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
/**
* Form bean for a Struts application.
* Users may access 1 field on this form:
* <ul>
* <li>projectName - [your comment here]
* </ul>
* @version 1.0
* @author
*/
public class sheduleForm extends ActionForm {
private
String projectName = null;
/**
* Get projectName
* @return String
*/
public String getProjectName() {
return projectName;
}
/**
* Set projectName
* @param <code>String</code>
*/
public void setProjectName(String p) {
this.projectName = p;
}
public void reset(ActionMapping mapping, HttpServletRequest request) {
// Reset values are provided as samples only. Change as appropriate.
projectName = null;
}
public ActionErrors validate(
ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
// Validate the fields in your form, adding
// adding each error to this.errors as found, e.g.
// if ((field == null) || (field.length() == 0)) {
// errors.add("field", new org.apache.struts.action.ActionError("error.field.required"));
// }
return errors;
}
}
---------------------------------------------------------
my
jsp ---------------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ page import="forms.sheduleForm" %>
<%
sheduleForm project = new sheduleForm();
String proj = project.getProjectName();
%>
<html:html>
<HEAD>
<%@ page
language="java"
contentType="text/html; charset=ISO-8859-1"
%>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<TITLE></TITLE>
</HEAD>
<BODY>
<P>
Test Shedule.</P>
<%
System.out.println("inside jsp"+proj);
%>
<P><%= project.getProjectName() %></P>
</BODY>
</html:html>
------------------------------------------------------
my strutsconfig
-------------------------------------------------------
<action path="/shedule1" type="actions.shedule1Action">
<forward name="success" path="/sheduled.jsp">
</forward>
</action>
i am getting projectname as null in JSP ?
thanks in advance