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
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Reply 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: 49
Hi Rahul

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

 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: The requested resource (Servlet action is not available) is not available in struts
 
Similar Threads
error while creating struts application
struts 1.beginner, code not working
Getting Problem in display tag with struts
How is a request handled within struts framework
The requested resource (/welcome) is not available." HTTP Status 404 - /welcome