hi,
i am doing one sample application in hibernate with struts .i kept one jsp welcome file in web.xml with welcome file list.in struts-config.xml,i mapped the action path in jsp to one Action class which extends struts Action class.When i am running the tomacat server its perfectly working.and welcome file is displayed.But on submitting following error is given in browser.
"HTTP Status 500 - No action instance for path /search could be created"
Attaching the welcome file and struts-config.xml:
1.web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<!-- Action Servlet Mapping -->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/search.jsp</welcome-file>
</welcome-file-list>
</web-app>
2.struts_config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">
<struts-config>
<form-beans>
<form-bean name="searchForm" type="java.Search"/>
</form-beans>
<action-mappings>
<action path="/search" type="java.SearchAction" input="/failure.jsp" scope="request">
<forward name="sucess" path="/sucess.jsp"/>
</action>
</action-mappings>
</struts-config>
3.jsp file:
<html>
<head>
<title>Front page</title>
</head>
<body bgcolor="lightgreen">
<form action="search.do">
id:<input type="text" name="txt1"/>
<input name=button type=submit value="Click">
<input name=button type=reset value="reset">
</form>
</body>
</html>
4.Action class:
package java;
import common.DAOException;
import java.io.*;
import java.util.*;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.log4j.Logger;
public class SearchAction extends Action
{
private static Logger log = Logger.getLogger(SearchAction.class.getName());
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res)throws IOException,ServletException
{
HttpSession session=req.getSession();
log.info("In Search Action");
Search se=(Search)form;
try
{
String name=SearchFascade.getSearchName(se);
session.setAttribute("name",name);
}
catch(DAOException daoexception)
{
daoexception.printStackTrace();
//return mapping.findForward("failure");
}
return mapping.findForward("sucess");
}
}
please give a solution.
regards,
Murali