aspose file tools*
The moose likes Struts and the fly likes The requested resource (Servlet action is not available) is not available in struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "The requested resource (Servlet action is not available) is not available in struts" Watch "The requested resource (Servlet action is not available) is not available in struts" New topic
Author

The requested resource (Servlet action is not available) is not available in struts

rahul deo
Greenhorn

Joined: Jul 05, 2011
Posts: 10
Hi
I am new to the struts application. I am creating a simple login page.

my web.xml files is
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>

my strus-config.xml file is


<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="MyLoginForm" type="com.tcs.bancs.actionform.MyLoginForm"/>

</form-beans>

<global-exceptions>

</global-exceptions>

<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
</global-forwards>

<action-mappings>
<action input="/Login.jsp" name="MyLoginForm" path="welcome.do" scope="request" type="com.vaannila.LoginAction">
<forward name="success" path="/success.jsp" />
<forward name="failure" path="/fail.jsp" />
</action>
<action path="/Welcome" forward="/login.jsp"/>
</action-mappings>
</struts-config>

my action class
public class MyLoginAction extends ActionServlet {
/**
*
*/
private static final long serialVersionUID = 1L;

public ActionForward execute (ActionMapping map, ActionForm form, HttpServletRequest req, HttpServletResponse res)
{
MyLoginForm login=(MyLoginForm) form;
if(login.getName()==login.getPassword())
{
return(map.findForward("success"));
}
else
{
return(map.findForward("fail"));
}

}

}

my login.jsp is

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Login</title>
</head>
<body>
<form action="welcome.do" method="post">
<input type="text" name="Name">
<input type="password" name="Password">
<input type="submit" value="SUBMIT">

</form>
</body>
</html>

after compiling , when i am executing this with url as http://localhost:8080/Sample/welcome.do

I am getting an error as The requested resource (Servlet action is not available) is not available, Please help me.

Thanks
Pyla Rao
Ranch Hand

Joined: Jul 10, 2012
Posts: 50
Hi Rahul

Your MyLoginAction class should be extend to Action not a ActionServlet.

 
Consider Paul's rocket mass heater.
 
subject: The requested resource (Servlet action is not available) is not available in struts