Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

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

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul

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

 
this is supposed to be a surprise, but it smells like a tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic