Win a copy of Functional Design and Architecture this week in the Functional programming 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Help - javax.servlet .ServletException: Cannot retrieve mapping for action

 
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im following an online tutorial and for the las t day i can't figure out why this won't work, i keep getting the error message javax.servlet .ServletException: Cannot retrieve mapping for action /login

My web.xml file which i think is ok is:

<?xml version="1.0" encoding="ISO-8859-1"?>



<!DOCTYPE web-app

PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"

"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">



<web-app>



<!-- Action Servlet Configuration -->

<servlet>

<servlet-name>action</servlet-name>

<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>



<!-- Resources bundle base class -->

<init-param>

<param-name>application</param-name>

<param-value>ApplicationResources</param-value>

</init-param>



<!-- Context-relative path to the XML resource containing Struts configuration information -->

<init-param>

<param-name>config</param-name>

<param-value>/WEB-INF/struts-config.xml</param-value>

</init-param>


<!-- Setting the locale parameter -->

<init-param>

<param-name>locale</param-name>

<param-value>true</param-value>

</init-param>


<!-- The debugging detail level for this servlet, which controls how much information is logged. -->

<init-param>

<param-name>debug</param-name>

<param-value>2</param-value>

</init-param>



<load-on-startup>2</load-on-startup>

</servlet>





<!-- Action Servlet Mapping -->

<servlet-mapping>

<servlet-name>action</servlet-name>

<url-pattern>*.do</url-pattern>

</servlet-mapping>





<!-- The Welcome File List -->

<welcome-file-list>

<welcome-file>registeruser/index.jsp</welcome-file>

</welcome-file-list>



<!-- Struts Tag Library Descriptors -->

<taglib>

<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>

</taglib>



<taglib>

<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-html.tld</taglib-location>

</taglib>



<taglib>

<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>

<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>

</taglib>



</web-app>


My struts-config.xml file which is where is think the problem is, is:

<?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>
Logon form bean
<form-bean name="LoginForm"
type="app.LoginForm"/>
</form-beans>

<global-forwards>
<forward name="mainmenu"path="/mainmenu.jsp" />
</global-forwards>

<action-mappings>

Process a user logon
<action path="/login"
type="src.LoginAction"
name="loginForm"
scope="session"
input="/index.jsp">
</action>
</action-mappings> -->

<message-resources parameter="application"/>


</struts-config>


And the LoginForm.class is

package src;
import org.apache.struts.action.*;
import javax.servlet.http.*;
import java.io.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class LoginForm extends ActionForm {

private String login;

private String password;

public User()
{}

public void setLogin(String login)
{ this.login = login; }

public void setPassword()
{ this.password = password; }

public String getLogin()
{ return this.login; }

}


It is a basic login tutorial from www. isabelle-hurbain.com

The page that is supposed to use the above is index.jsp

<%@ page language="java" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<%@ taglib uri="/WEB-INF/struts-form.tld" prefix="form" %>

<html:html locale="true">

<head>

<title>Welcome to RegisterUser</title>

</head>



<body>
HI
<!--
<form:form action="/login">
Login:<form:text property="login" />
<br />
Password:<form assword property="password" />
<br />
<form:submit>
Login
</form:submit>
</form:form> -->
</body>
</html:html>


And finally the layout of my project is

Project
- registeruser
- index.jsp
- WEB-INF
- classes
- ApplicationResources.properties
- ApplicationResources_de.properties
- lib
- All the .jar files
- src
- LoginForm.class
- web.xml
- struts-config.xml
- All the strut .tld files



Any help at all will be most appreciated

Thanx

 
Nicola Guy
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just noticed the commetns in the strut-config.xml file, these were inserted so i could check the problem elsewhere i removed these and stil get an error message but its now

javax.servlet.ServletException: Exception creating bean of class app.LoginForm: {1}
 
Ranch Hand
Posts: 250
Python Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.geocities.com/Colosseum/Field/7217/SW/struts/errors.html
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving this to the Web Frameworks forum.

Mark
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic