Hi , i need to know that, what do i need to edit in the action class or if here to route my page according to the option i select from the html:option.
i am a newbie so little help will be required.
Do i need to edit anythin in the action class..? or do ihave to do it here??
JSP PAGE
<%@ 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">
<%@ taglib uri="WEB-INF/tlds/struts-html" prefix="html"%>
<%@ taglib uri="WEB-INF/tlds/struts-logic" prefix="logic"%>
<%@ taglib uri="WEB-INF/tlds/struts-bean" prefix="bean"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h1 align="center"><u>Table 1</u></h1>
<html:form action="/hello" method="post" >
<table id="cs1" width="" border="0" align="center" bgcolor="white" >
<tr>
<th align="center">
Name<html:text property="Name" />
</th>
</tr>
<tr>
<th align="center">From Date <html:text property="fromDate" /></th>
</tr>
<tr>
<th align="center" >
To Date <html:text property="toDate" />
</th>
</tr>
<tr>
<th align="center" >
Type<html:select property="Type" size="1" >
<html:option value="0">A </html:option>
<html:option value="1">B</html:option>
<html:option value="2">C</html:option>
</html:select>
</th>
</tr>
<tr>
<th align="center">
2Name<html:select property="2Name" size="1" >
<html:option value="0"> J2</html:option>
<html:option value="1"> J1</html:option>
<html:option value="2"> J3</html:option>
</html:select>
</th>
</tr>
<tr></tr>
<tr>
<th>
<html:submit />
</th>
</tr>
</table>
</html:form>
</body>
</html>
ACTION CLASS
package ui.web.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
public class CommonServicesAction extends Action{public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request,HttpServletResponse response)throws Exception
{
return mapping.findForward("success3");
}}
Struts config
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
<!-- ========== Form Bean Definitions ============ -->
<form-beans>
<form-bean name="HelloForm" type="ui.web.struts.action.HelloForm" />
</form-beans>
<!-- ========== Action Mapping Definitions ======== -->
<action-mappings>
<action
path="/hello"
type="ui.web.struts.action.helloAction"
name="HelloForm"
scope="session"
validate="true"
>
<forward name="success3" path="/hellohello.jsp" />
</action>
</action-mappings>
</struts-config>
Action FORM
import org.apache.struts.action.*;
public class CommonServicesForm extends ActionForm{
private
String Name=null;
private Object fromDate=null;
private Object toDate=null;
private String Type;
private String 2Name;
public void setFromDate(Object fromDate) {
this.fromDate = fromDate;
}
public Object getFromDate() {
return this.fromDate;
}
public void setName(String Name) {
this.Name = Name;
}
public String getName() {
return this.Name;
}
public void setToDate(Object toDate) {
this.toDate = toDate;
}
public Object getToDate() {
return toDate;
}
public void setType(String Type) {
this.Type = Type;
}
public String getType() {
return Type;
}
public void set2Name(String 2Name) {
this.2Name = 2Name;
}
public String get2Name() {
return 2Name;
}
}