Posting data from .jsp to execute( ) method
Hi All,
Still learning Struts . . .
I'm currently just trying to post my data from my .jsp to my execute
( ) method in my Action Class. For some reason, I don't see the data
from my .jsp being populated in the ActionForm form object in the
execute method when I submit my .jsp. Obviously, missing
something . . . Can someone help me out???
The .jsp, some of the struts-config.xml, and action class are shown
below:
****************** adddefect.jsp **********************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@taglib uri="http://displaytag.sf.net" prefix="display" %>
<%@taglib uri="http://displaytag.sf.net/el" prefix="displayel" %>
<%@taglib uri="http://jakarta.apache.org/taglibs/datagrid-1.0"
prefix="ui" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html:html>
<head>
<title>adddefect</title>
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<link rel="stylesheet" href="styles/form.css" type="text/css">
</head>
<body>
<html:form action="adddefect" method="post">
<table class="tableinputform" >
<tr>
<th>Description</th>
<td><input type="text" name="Description"/></td>
</tr>
<tr>
<th>PriorityID</th>
<td><input type="text" name="Priorityid"/></td>
</tr>
<tr>
<th>ReportDateTime</th>
<td><input type="text" name="Reportdatetime"/></td>
</tr>
<tr>
<th>ReporterUserID</th>
<td><input type="text" name="Reporteruserid"/></td>
</tr>
<tr>
<th>FunctionalAreaID</th>
<td><input type="text" name="Functionalareaid"/></td>
</tr>
<tr>
<th>StatusID</th>
<td><input type="text" name="Statusid"/></td>
</tr>
<tr>
<th>Severity</th>
<td><input type="text" name="Severity"/></td>
</tr>
<tr>
<th>TeamLeadID</th>
<td><input type="text" name="Teamleadid"/></td>
</tr>
<tr>
<th>DetectionDateTime</th>
<td><input type="text" name="Detectiondatetime"/></td>
</tr>
<tr>
<th>EstFixTime</th>
<td><input type="text" name="Estfixtime"/></td>
</tr>
<tr>
<th>ActFixTime</th>
<td><input type="text" name="Actfixtime"/></td>
</tr>
<tr>
<th>StatusDate</th>
<td><input type="text" name="Statusdate"/></td>
</tr>
<tr>
<th>AssignedToUserID</th>
<td><input type="text" name="Assignedtouserid"/></td>
</tr>
<tr>
<th>AssignedToDate</th>
<td><input type="text" name="Assignedtodate"/></td>
</tr>
<tr>
<th>FixedByUserID</th>
<td><input type="text" name="Fixedbyuserid"/></td>
</tr>
</table>
<html:submit property="actionButton" value="Submit"
styleClass="submit"/>
</html:form>
</body>
</html:html>
************************ a portion of struts-config.xml
**********************************
<action path="/adddefect"
type="DBOperations"
name="DefectForm"
input="/error.jsp"
scope="session"
cancellable="true"
validate="true">
<forward name="success" path="/showdefects.jsp"/>
<forward name="failure" path="/submitpage.jsp"/>
</action>
****************** Action Class **********************************
package gov.ohio.odjfs.struts;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
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.action.ActionMessage;
public class DBOperations extends Action
{
public DBOperations()
{
super();
}
public ActionForward execute (ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws
Exception
{
ActionErrors errors = new ActionErrors();
ActionForward forward = new ActionForward();
ArrayList fd = new ArrayList();
Defect df = (Defect)form;
Enumeration en = request.getParameterNames();
/*while (en.hasMoreElements())
{
String paramName = (String) en.nextElement();
fd.add(request.getParameter(paramName));
}*/
//request.getParameter("Description");
//DefectListObject DLO = new DefectListObject();
try
{
EricEnhancementServiceImpl E = new EricEnhancementServiceImpl();
E.InsertDefects(form);
}
catch (Exception e)
{
// Report the error using the appropriate name and ID.
errors.add("name", new ActionMessage("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);
}
// Write logic determining how the user should be forwarded.
forward = mapping.findForward("success");
// Finish with
return (forward);
}
}