Hi all,
this there a way to check if my actionclass is being call. I tried to put the Systm.out.println. but nothing is display so i assumed my action is not being call.
Im using
Struts 1.3.5
Action Class:
private final static
String SUCCESS = "success";
public ActionForward insert(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
System.out.println("action");
ContentForm cfrm = (ContentForm) form;
Session session = null;
System.out.println(cfrm.getContent());
try{
SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set values in it by reading them from form object
System.out.println("Inserting Record");
Content content = new Content();
content.setContent(cfrm.getContent());
content.setName(cfrm.getName());
content.setFile(cfrm.getFile());
content.setTitle(cfrm.getTitle());
session.save(content);
System.out.println("Done");
}catch (Exception e)
{
System.err.print(e.getStackTrace());
}
return mapping.findForward(SUCCESS);
}
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/dtds/struts-config_1_3.dtd">
<!--
This is a blank Struts configuration file with an example
welcome action/page and other commented sample elements.
Struts Validator is configured using the factory defaults
and is ready-to-use.
NOTE: If you have a generator tool to create the corresponding
Java classes
for you, you could include the details in the "form-bean" declarations.
Otherwise, you would only define the "form-bean" element itself, with the
corresponding "name" and "type" attributes, as shown here.
-->
<struts-config>
<form-beans>
<form-bean name="contentForm"
type="com.strutsexample.form.ContentForm"/>
</form-beans>
<action-mappings>
<action path="/list"
name="contentForm"
scope="request"
parameter="method"
type="com.strutsexample.action.ContentAction">
<forward name="success" path="/list.jsp"/>
</action>
<action path="/insert" forward="/insert.jsp"/>
<action path="/listAdd"
name="contentForm"
scope="request"
input="/insert.jsp"
parameter="method"
type="com.strutsexample.action.ContentAction">
<forward name="success" path="/list.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.strutsexample.message" null="false"/>
</struts-config>
JSP page:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<html:form action="/listAdd" method="get">
<table>
<tr><td><bean:message key="label.name"/></td><td><html:text property="name"/></td></tr>
<tr><td><bean:message key="label.title"/></td><td><html:text property="title"/></td></tr>
<tr><td><bean:message key="label.content"/></td><td><html:textarea property="content"/></textarea></td></tr>
<tr><td><bean:message key="label.file"/></td><td><html:file property="file"/></td></tr>
<tr><td> <html:hidden property="method" value="insert" />
<html:submit value="submit"></html:submit></td><td></td></tr>
</table>
</html:form>