HTTP Status 404

Senhores podem me ajudar no caso abaixo:

<?xml version="1.0" ?>
<!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>
	
	<!-- Standard Action Servlet Configuration (with debugging) -->
  	<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>
	    
    	<init-param>
	      <param-name>debug</param-name>
    	  <param-value>3</param-value>
	    </init-param>
    	<init-param>
	      <param-name>detail</param-name>
    	  <param-value>3</param-value>
	    </init-param>
    	<load-on-startup>1</load-on-startup>
	</servlet>
    
    <!-- Standard Action Servlet Mapping -->
	<servlet-mapping>
    	<servlet-name>action</servlet-name>
	    <url-pattern>*.do</url-pattern>
	</servlet-mapping>
    

	<welcome-file-list>
		<welcome-file>index.jsp</welcome-file>
	</welcome-file-list>
	
	<!-- Struts Tag Library Descriptors -->
  	<taglib>
    	<taglib-uri>/tags/struts-bean</taglib-uri>
    	<taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
  	</taglib>

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

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

  	<taglib>
    	<taglib-uri>/tags/struts-nested</taglib-uri>
    	<taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
  	</taglib>

  	<taglib>
    	<taglib-uri>/tags/struts-tiles</taglib-uri>
    	<taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
  	</taglib>

	<taglib>
    	<taglib-uri>jstl/c</taglib-uri>
	    <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
	</taglib>
	<taglib>
    	<taglib-uri>jstl/fmt</taglib-uri>
	    <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location>
	</taglib>
	
	<taglib>
		<taglib-uri>jtl/cal</taglib-uri>
		<taglib-location>/WEB-INF/tld/cal.tld</taglib-location>
	</taglib>
	
	<taglib>
		<taglib-uri>jtl/displaytag</taglib-uri>
		<taglib-location>/WEB-INF/tld/displaytag-11.tld</taglib-location>
	</taglib>

</web-app>
<?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="registerForm" type="com.livro.RegisterForm"/>
				</form-beans>
				
				<action-mappings>
					<action path="/register"
							type="com.livro.RegisterAction"
							name="registerForm">
					
					<forward name="sucess" path="/sucess.jsp"/>
					<forward name="erro" path="/erro.jsp"/>
					</action>
				</action-mappings>
					
			</struts-config>
<%@ taglib uri="WEB-INF/tld/struts-html.tld" prefix="html"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

	<html:form action="register.jsp">
	
		Nome:<html:text property="nome"/><br>
		Senha1:<html:text property="senha1"/><br>
		Senha2:<html:text property="senha2"/><br>
	
	<html:submit value="Register" />
	</html:form>
</body>
</html>
package com.livro;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class RegisterAction extends Action{

	public ActionForward perfom(ActionMapping map, ActionForm form, HttpServletResponse response, HttpServletRequest request){
		
		RegisterForm rf = (RegisterForm) form;
		ActionForward retorno = null;
		
		String username = rf.getNome();
		String password1 = rf.getSenha1();
		String password2 = rf.getSenha2();
		
		if (password1.equals(password2)) {
			try{
				retorno =  map.findForward("sucesso");
			}catch (Exception e) {
				retorno = map.findForward("erro");
				
			}
		}
		return retorno;
	}
}
package com.livro;

import org.apache.struts.action.ActionForm;

public class RegisterForm extends ActionForm{

	private String nome;
	private String senha1;
	private String senha2;
	
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getSenha1() {
		return senha1;
	}
	public void setSenha1(String senha1) {
		this.senha1 = senha1;
	}
	public String getSenha2() {
		return senha2;
	}
	public void setSenha2(String senha2) {
		this.senha2 = senha2;
	}
	
	
	
}

HTTP Status 404 - /exercicio-livro/
description The requested resource (/exercicio-livro/) is not available.

Esta dando esse erro, vcs podem me???

Obrigado…

Verifique a url que está no submit do seu form…

Ali vc está apontando para uma página JSP, quando deveria apontar para a Action de Registro.

com erro ==> &lt;html:form action="register.jsp"&gt;
correto ==> &lt;html:form action="register"&gt;

Erro 404 até onde eu sei é a pagina q não foi encontrada…

Entao já fiz essa correção e o problema continua…de fato ele nao esta encontrando a pagina mas no meu ver esta tudo certo…alguem pode me ajduar…???

Bem… vc ainda precisa verificar umas outras configurações, tais como:

a) Se as páginas "succes.jsp" e "erro.jsp" existem.

b) Se o mapeamento está correto no arquivo struts-config (veja abaixo)
no código ->[code]
if (password1.equals(password2)) {
try{
retorno = map.findForward("sucesso");
}catch (Exception e) {
retorno = map.findForward("erro");

         }  
     }  
     return retorno;  

[/code]
no struts-config ->[code]
<action-mappings>
<action path="/register"
type="com.livro.RegisterAction"
name=“registerForm”>

                 &lt;forward name="sucess" path="/sucess.jsp"/&gt;  
                 &lt;forward name="erro" path="/erro.jsp"/&gt;  
                 &lt;/action&gt;  
             &lt;/action-mappings&gt;  

[/code]

  • Vc está chamando no código um mapeamento com nome “sucesso” que não está no struts-config. No struts-config, o mepeamento está com nome “sucess”

Ainda existe um outro erro nesse código: pode ser que seu retorno seja NULL, basta apenas que passsword1 seja diferente de password2

         ActionForward retorno = null;  
           
         String username = rf.getNome();  
         String password1 = rf.getSenha1();  
         String password2 = rf.getSenha2();  
           
         if (password1.equals(password2)) {  
             try{  
                 retorno =  map.findForward("sucesso");  
             }catch (Exception e) {  
                 retorno = map.findForward("erro");  
                   
             }  
         }  
         return retorno; 

Colega Rolemberg

Estou com um problema parecido com o seu !!!

Um Menu chamando uma JSP (tudo certo)

quando clico em qq botão da JSP dá o mesmo erro que você está falando e aparentemente está tudo certinho.

Mapeamento, WEB.XML, Servlet tudo certo.

Um colega muito atencioso aqui do Forum, o Ramon, está tentando me ajudar em MP mas até agora não encontramos a solução pois ele tentou lá e não deu erro.

Ainda estou procurando solução

Vimieiro

Então achei um pots aqui no forum que o cara estava com o mesmo problema (assunto do post: Struts erro, no tomcat )…

todas as exigencias do post eu fiz e continua dando o mesmo erro…se alguem puder me ajudar, fico grato…novamente vou postar o codigo, xml, properties e a arquitetura…

   Arquitetura

projeto
|
|javaResources
    |src
    |
    |resources
|
|WebContent
    |
     WEB-INF
     |lib
     |tld
     |struts-config.xml
     |web.xml
|paginas jsp

*alguns itens foram omitidos pois nao vejo necessidade de colcoar...se tiver me avisem...
//Action...
package com.livro;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LivroAction extends Action{

	public ActionForward execute(HttpServletRequest req, HttpServletResponse resp,
								ActionMapping map, ActionForm form){
		
		ActionForward retorno=null;
		
		LivroForm lf = (LivroForm)form;
		
		String usuario = lf.getUsuario();
		String senha1 = lf.getSenha1();
		String senha2 = lf.getSenha2();
		
		if (senha1.equals(senha2)) {
			req.setAttribute(usuario, usuario);
			retorno = map.findForward("sucesso.jsp");
		}else{
			retorno = map.findForward("erro.jsp");
		}
		
		return retorno;
	}
}
//ActionForm
package com.livro;

import org.apache.struts.action.ActionForm;

public class LivroForm extends ActionForm{

	private String usuario;
	private String senha1;
	private String senha2;
	
	public String getUsuario() {
		return usuario;
	}
	public void setUsuario(String usuario) {
		this.usuario = usuario;
	}
	public String getSenha1() {
		return senha1;
	}
	public void setSenha1(String senha1) {
		this.senha1 = senha1;
	}
	public String getSenha2() {
		return senha2;
	}
	public void setSenha2(String senha2) {
		this.senha2 = senha2;
	}
	
}
struts-config.xml

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

	<!DOCTYPE struts-config PUBLIC   
              "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"   
              "http://struts.apache.org/dtds/struts-config_1_1.dtd">   
  
<struts-config>   
    <form-beans>   
        <form-bean name="livroForm" type="com.livro.LivroForm" />   
    </form-beans>   
    <action-mappings>   
        <action path="/livro"
        		type="com.br.LivroAction"
        		name="livroForm">
        		   
            <forward name="sucesso" path="/sucesso.jsp" />   
            <forward name="erro" path="/erro.jsp" />   
        </action>   
    </action-mappings>
    
    <message-resources parameter="resources.application" />   
</struts-config> 
//web.xml

<?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>

  <!-- Standard Action Servlet Configuration (with debugging) -->
  <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>
    <init-param>
      <param-name>debug</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>detail</param-name>
      <param-value>2</param-value>
    </init-param>
    <init-param>
      <param-name>application</param-name>
       <param-value>resources.application</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>


  <!-- Standard Action Servlet Mapping -->
  <servlet-mapping>
    <servlet-name>action</servlet-name>
    <url-pattern>*.do</url-pattern>
  </servlet-mapping>


  <!-- The Usual Welcome File List -->
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>


  <!-- Struts Tag Library Descriptors -->
  <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location>
  </taglib>

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

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

  <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location>
  </taglib>

  <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location>
  </taglib>

</web-app>
application.properties
//esse arquivo arquivo esta na pasta resources

# Errors   
errors.footer=   
errors.header=<h3><font color="red">Erro de Validação</font></h3>You must correct the following error(s) before proceeding:   
errors.ioException=I/O exception rendering error messages: {0}   
error.database.missing=<li>User database is missing, cannot validate logon credentials</li>   
errors.required={0} é obrigatório.   
errors.minlength={0} can not be less than {1} characters.   
errors.maxlength={0} can not be greater than {1} characters.   
errors.invalid={0} é invalido.   
  
errors.byte={0} must be an byte.   
errors.short={0} must be an short.   
errors.integer={0} must be an integer.   
errors.long={0} must be an long.   
errors.float={0} must be an float.   
errors.double={0} must be an double.   
  
errors.date={0} is not a date.   
  
errors.range={0} is not in the range {1} through {2}.   
  
errors.creditcard={0} is not a valid credit card number.   
  
errors.email={0} is an invalid e-mail address.  

Peço desculpa pelo tamanho do post e que estou desenvolvendo uma aplicação e gostaria de usar struts mas esta dificil de entender o erro: Cannot find ActionMappings or ActionFormBeans collection
que parece ser generico…se alguem puder me ajudar fico muito grato…