Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/04/2010, 21:38
GermanGaita
 
Fecha de Ingreso: abril-2009
Mensajes: 53
Antigüedad: 15 años, 9 meses
Puntos: 1
Respuesta: Struts - Error con formulario

He descubierto que el error debe estar en algo de la configuracion de mi hosting o en algun path.
Para confirmar que el problema era del hosting hice esta simple aplicacion.

Este es mi index.jsp
Código PHP:
<%@ 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" %>

<
html:form action="contactos">
  <
html:text property="nombre" value="" maxlength="12"></html:text><br />
  <
html:submit value="Enviar" property="enviar"></html:submit><br/>
  <
html:errors property="name"/><br />

  <%
       if(
request.getSession().getAttribute("ingreso") != null)
       {
            
out.println((String)request.getSession().getAttribute("ingreso"));
       }
       else { 
out.println("no ingreso nada men"); }
  %>
</
html:form
este mi ActionForm Bean, "contactos":
Código:
import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class contactos extends org.apache.struts.action.ActionForm {
    
    private String nombre;
    
    public contactos() { super(); }

    public String getNombre() { return nombre; }

    public void setNombre(String nombre) { this.nombre = nombre; }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getNombre() == null || getNombre().length() < 1) {
            errors.add("name", new ActionMessage("error.name.required"));  }
        return errors;
    }
}

este mi ActionForm, "contactos":
Código:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class contactos extends org.apache.struts.action.Action {
    
   private Controladores.Form.contactos formulario;

   public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        formulario=(Controladores.Form.contactos) form;
        request.getSession().setAttribute("ingreso", formulario.getNombre());
        return mapping.getInputForward();
    }
}
mi struts-config.xml
Código PHP:
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC
          "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN"
          "http://jakarta.apache.org/struts/dtds/struts-config_1_3.dtd">

<struts-config>
    <form-beans>
        <form-bean name="contactos" type="Controladores.Form.contactos"/>
    </form-beans>
    
    <global-exceptions>
    
    </global-exceptions>

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

    <action-mappings>
        <action input="/index.jsp" name="contactos" path="/contactos" scope="session" type="Controladores.Action.contactos"/>
        <action path="/Welcome" forward="/welcomeStruts.jsp"/>
    </action-mappings>
    
    <controller processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>

    <message-resources parameter="com/myapp/struts/ApplicationResource"/>    
   
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
        <set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />      
        <set-property property="moduleAware" value="true" />
    </plug-in>
    
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property
            property="pathnames"
            value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
  
</struts-config>
Al probar el codigo en el servidor local funciona sin problemas, el tema esta al subirlo a mi hosting, nose si tengo que acomodar algo de algun path en el struts-config.xml la verdad ya no se donde buscar.
Dentro de mi hosting ubico los archivos dentro del directorio "/public_html/miaplicacion"
El error surge cuando lleno el campo de texto y presiono el boton enviar, me salta el siguiente error:
Código:
Not Found
The requested URL /adictosms/contactos.do;jsessionid=27BEEDDB2EE19BE78DFE2901528783E6 was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.