You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pushpendra Maharya <pu...@hic-soft.co.jp> on 2005/08/04 04:52:24 UTC

Action not getting called

HI,
  I am trying to solve thi sproblem from last 2 days but did not get any
success.Except this all the actions are getting called and working fine.

Action Class


package site;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import common.SelectMenuForm;

public class AddSiteAction extends Action{
    
    private String strPage = "NG";
    
    public ActionForward exceute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)throws Exception{
        
        HttpSession session = request.getSession(false);
        String loginid = (String)session.getAttribute("loginid");
        if(loginid==null||loginid.equals("")){
            strPage ="login";
            return mapping.findForward(strPage);
        }
        
        SelectMenuForm smform = (SelectMenuForm)form;            
        String siteid = smform.getSiteid();
        System.out.println("Add Site called");
        
        try{
            DataSource dataSource = getDataSource(request);
            Connection con = dataSource.getConnection();
            Statement stmt = con.createStatement();
            
            StringBuffer strBuf = new StringBuffer();
            strBuf.append("INSERT INTO SITE VALUES('");
            strBuf.append(smform.getSiteid());
            strBuf.append("', '");
            strBuf.append(smform.getSITENAME());
            strBuf.append("', '");
            strBuf.append(smform.getREMARKS());
            strBuf.append("', ");
            strBuf.append("SYSDATE ,");
            strBuf.append("SYSDATE ");
            strBuf.append(")");
            System.out.println(strBuf.toString());
            ResultSet rs = stmt.executeQuery(strBuf.toString());
            if(rs.next()){
                strPage = "success";
            }
        }catch (Exception e){
            String message = "入力できませんでした。";
            request.setAttribute("message" , message);
            return mapping.findForward(strPage);
        }
        
        return mapping.findForward(strPage);
        
    }
    
}

JSP

<%@ page contentType="text/html; charset=Shift_JIS" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>

<html:html>
<head>
<title></title>
</head>
<body>
	<html:form action="addsite">
	<table border="0" cellpadding="4" cellspacing="0" width="510">
		<tr bgcolor=#FFCC00>
			<td nowrap><strong><font color="#104A7B">サイト設定 ≫<bean:write name= "smform" property="siteid"/></font></strong></td>
		</tr>
		<logic:notPresent name="loginid" parameter="loginid" scope="session">
			<logic:forward name="login" />
		</logic:notPresent>
		<tr>
			<td align="center">
				<table border="0" cellpadding="2" cellspacing="2" width="">
					<tr bgcolor=#FFCC00>
						<td nowrap>名称</td>
						<td colspan="3" nowrap>設定値</td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>サイトID</td>
						<td nowrap><bean:write name="smform" property="siteid" /></td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>サイト名</td>
						<td nowrap><bean:write name="smform" property="SITENAME"/></td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>備考</td>
						<td nowrap><bean:write name="smform" property="REMARKS"/></td>
					</tr>
					
					<tr>
						<td colspan="4" align="right">
						
							<html:submit property="success" value="登録" />
							<html:button property="success" value="戻る" onclick="javascript:history.go(-1);" />

						</td>
					</tr>
				
				</table>
			</td>
		</tr>
	</table>
</html:form>
</body>

</html:html>

and strust mapping is

action
			path="/addsite"
            type="site.AddSiteAction"
			name="SelectMenuForm"
            scope="request">
			<forward name="success" path="/sitelist.do"/>
      		<forward name="NG" path="/jsp/error.jsp"/>
	</action>

If anyone can help than it will be really appreciative.Thanks in advance.
-- 
Pushpendra Maharya <pu...@hic-soft.co.jp>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Action not getting called

Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Interesting method signature:

public ActionForward exceute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)throws Exception{

Shouldn't that be "execute" not "execeute" ?

Regards,
David

-----Original Message-----
From: Pushpendra Maharya [mailto:pushpendra@hic-soft.co.jp]
Sent: Wednesday, August 03, 2005 10:52 PM
To: user@struts.apache.org
Subject: Action not getting called


HI,
  I am trying to solve thi sproblem from last 2 days but did not get any
success.Except this all the actions are getting called and working fine.

Action Class


package site;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.sql.DataSource;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import common.SelectMenuForm;

public class AddSiteAction extends Action{

    private String strPage = "NG";

    public ActionForward exceute(ActionMapping mapping,
            ActionForm form,
            HttpServletRequest request,
            HttpServletResponse response)throws Exception{

        HttpSession session = request.getSession(false);
        String loginid = (String)session.getAttribute("loginid");
        if(loginid==null||loginid.equals("")){
            strPage ="login";
            return mapping.findForward(strPage);
        }

        SelectMenuForm smform = (SelectMenuForm)form;
        String siteid = smform.getSiteid();
        System.out.println("Add Site called");

        try{
            DataSource dataSource = getDataSource(request);
            Connection con = dataSource.getConnection();
            Statement stmt = con.createStatement();

            StringBuffer strBuf = new StringBuffer();
            strBuf.append("INSERT INTO SITE VALUES('");
            strBuf.append(smform.getSiteid());
            strBuf.append("', '");
            strBuf.append(smform.getSITENAME());
            strBuf.append("', '");
            strBuf.append(smform.getREMARKS());
            strBuf.append("', ");
            strBuf.append("SYSDATE ,");
            strBuf.append("SYSDATE ");
            strBuf.append(")");
            System.out.println(strBuf.toString());
            ResultSet rs = stmt.executeQuery(strBuf.toString());
            if(rs.next()){
                strPage = "success";
            }
        }catch (Exception e){
            String message = "入力できませんでした。";
            request.setAttribute("message" , message);
            return mapping.findForward(strPage);
        }

        return mapping.findForward(strPage);

    }

}

JSP

<%@ page contentType="text/html; charset=Shift_JIS" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>

<html:html>
<head>
<title></title>
</head>
<body>
	<html:form action="addsite">
	<table border="0" cellpadding="4" cellspacing="0" width="510">
		<tr bgcolor=#FFCC00>
			<td nowrap><strong><font color="#104A7B">サイト設定 ≫<bean:write
name= "smform" property="siteid"/></font></strong></td>
		</tr>
		<logic:notPresent name="loginid" parameter="loginid" scope="session">
			<logic:forward name="login" />
		</logic:notPresent>
		<tr>
			<td align="center">
				<table border="0" cellpadding="2" cellspacing="2" width="">
					<tr bgcolor=#FFCC00>
						<td nowrap>名称</td>
						<td colspan="3" nowrap>設定値</td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>サイトID</td>
						<td nowrap><bean:write name="smform" property="siteid" /></td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>サイト名</td>
						<td nowrap><bean:write name="smform" property="SITENAME"/></td>
					</tr>
					<tr bgcolor="#CCCCCC">
						<td nowrap>備考</td>
						<td nowrap><bean:write name="smform" property="REMARKS"/></td>
					</tr>

					<tr>
						<td colspan="4" align="right">

							<html:submit property="success" value="登録" />
							<html:button property="success" value="戻る"
onclick="javascript:history.go(-1);" />

						</td>
					</tr>

				</table>
			</td>
		</tr>
	</table>
</html:form>
</body>

</html:html>

and strust mapping is

action
			path="/addsite"
            type="site.AddSiteAction"
			name="SelectMenuForm"
            scope="request">
			<forward name="success" path="/sitelist.do"/>
      		<forward name="NG" path="/jsp/error.jsp"/>
	</action>

If anyone can help than it will be really appreciative.Thanks in advance.
--
Pushpendra Maharya <pu...@hic-soft.co.jp>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org