Foros del Web » Programación para mayores de 30 ;) » Java »

[SOLUCIONADO] El recurso requerido.

Estas en el tema de El recurso requerido. en el foro de Java en Foros del Web. ALGUIEN ME PODRA DECIR CUAL ES EL MOTIVO DE ESTE ERROR: El recurso requerido (/uploadFile) no está disponible. el uploadfile lo llamo <form method="POST" enctype="multipart/form-data" ...
  #1 (permalink)  
Antiguo 22/11/2011, 13:30
Avatar de yamiblancoc  
Fecha de Ingreso: agosto-2011
Mensajes: 103
Antigüedad: 12 años, 8 meses
Puntos: 4
Sonrisa El recurso requerido.

ALGUIEN ME PODRA DECIR CUAL ES EL MOTIVO DE ESTE ERROR:

El recurso requerido (/uploadFile) no está disponible.

el uploadfile lo llamo

<form method="POST" enctype="multipart/form-data" action="/uploadFile" >


Y CUAL ES LA SOLUCION PORQUE TENGO UNA SEMANA EN ESTO Y BUSCO POR INTERNET Y NO CONSIGO SOLUCIONES...


GRACIAS A QUIENES ME PUEDAN AYUDAR
  #2 (permalink)  
Antiguo 22/11/2011, 15:51
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: El recurso requerido.

Cita:
Iniciado por yamiblancoc Ver Mensaje
ALGUIEN ME PODRA DECIR CUAL ES EL MOTIVO DE ESTE ERROR:

El recurso requerido (/uploadFile) no está disponible.

el uploadfile lo llamo

<form method="POST" enctype="multipart/form-data" action="/uploadFile" >


Y CUAL ES LA SOLUCION PORQUE TENGO UNA SEMANA EN ESTO Y BUSCO POR INTERNET Y NO CONSIGO SOLUCIONES...


GRACIAS A QUIENES ME PUEDAN AYUDAR
Dejanos ver tu DD (Deployment Descriptor). Lo mas probable es que no hayas declarado correctamente tu Servlet en tu web.xml
  #3 (permalink)  
Antiguo 24/11/2011, 07:38
Avatar de yamiblancoc  
Fecha de Ingreso: agosto-2011
Mensajes: 103
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: El recurso requerido.

mi web.xml


Código java:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  3.  
  4.  
  5.  
  6.   <display-name>tilesExample</display-name>
  7.  
  8.   <context-param>
  9.         <param-name>contextConfigLocation</param-name>        
  10.         <param-value>/WEB-INF/dispatcher-servlet.xml,/WEB-INF/dispatcher-conection.xml</param-value>
  11.   </context-param>
  12.   <listener>
  13.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  14.   </listener>
  15.   <servlet>
  16.         <servlet-name>dispatcher</servlet-name>
  17.         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  18.         <load-on-startup>1</load-on-startup>
  19.     </servlet>
  20.     <servlet-mapping>
  21.         <servlet-name>dispatcher</servlet-name>
  22.         <url-pattern>*.htm</url-pattern>
  23.     </servlet-mapping>
  24. <welcome-file-list>
  25.         <welcome-file>redirect.jsp</welcome-file>
  26.     </welcome-file-list>
  27.    
  28.  
  29. </web-app>




y tengo otro que se llama dispatcher-servlet.xml

Código java:
Ver original
  1. ?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4.     xmlns:p="http://www.springframework.org/schema/p"
  5.     xmlns:context="http://www.springframework.org/schema/context"
  6.     xsi:schemaLocation="
  7.    http://www.springframework.org/schema/beans
  8.    http://www.springframework.org/schema/beans/spring-beans.xsd
  9.    http://www.springframework.org/schema/context
  10.    http://www.springframework.org/schema/context/spring-context.xsd">
  11.    
  12.     <bean id="viewResolver" class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
  13.         <property name="basename"><value>views</value></property>
  14.     </bean>
  15.    
  16.     <bean id="messageSource"
  17.         class="org.springframework.context.support.ResourceBundleMessageSource">     
  18.         <property name="basenames">
  19.         <list>         
  20.             <value>messages</value>
  21.             <value>hql</value>
  22.         </list>
  23.         </property>    
  24.     </bean>
  25.    
  26.     <bean id="tilesConfigurer"
  27.         class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
  28.         <property name="definitions">
  29.             <list>
  30.                 <value>/WEB-INF/tiles-defs.xml</value>
  31.             </list>
  32.         </property>
  33.     </bean>    
  34.    
  35.     <!--  -->
  36.     <bean  name="/ejemplo.htm" class="ve.gob.fii.web.EjemploController">
  37.         <property name="ejemploService" ref="ejemploService" />
  38.     </bean>
  39.     <bean  id="ejemploService" class="ve.gob.fii.service.EjemploService">
  40.         <property name="service" ref="GeneralDaoImpl" />
  41.     </bean>
  42.    
  43.     <bean  name="/office.htm" class="ve.gob.fii.web.OfficeController">
  44.         <property name="CommandName" value="ve.gob.fii.model.office"/>
  45.     </bean>
  46.    
  47.    
  48.     <!--  -->
  49.     <bean  name="/uploadFile.htm" class="ve.gob.fii.web.uploadFile"></bean>
  50.     <bean name="/inicio.htm"    class="ve.gob.fii.web.InicioController"></bean>
  51.     <bean name="/welcome.htm"   class="ve.gob.fii.web.WelcomeController"/>
  52. </beans>
  #4 (permalink)  
Antiguo 24/11/2011, 08:57
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: El recurso requerido.

En tu configuracion tienes declarado:
<bean name="/uploadFile.htm" class="ve.gob.fii.web.uploadFile"></bean>

Pero en tu codigo solo llamas a /uploadFile.
Agregale el .htm y deberia funcionar a menos que haya algun otro inconveniente.

Un saludo ;)
  #5 (permalink)  
Antiguo 24/11/2011, 10:13
Avatar de yamiblancoc  
Fecha de Ingreso: agosto-2011
Mensajes: 103
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: El recurso requerido.

Pues no funciona creeme que lo he puesto de mil y un forma con .htm, sin .htm, con .java, con la direccion /servlet/uploadFile y nada.... Siempre me dice

El recurso requerido (/uploadFile(ya sea /uploadFile o /uploasFile.htm o /servlet/uploadFile.... etc...) no está disponible
  #6 (permalink)  
Antiguo 24/11/2011, 10:31
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: El recurso requerido.

Muestrame el archivo ve.gob.fii.web.uploadFile

Lo que quiero verificar es si estas heredando de HttpServlet. Si es asi, trata agregando el uploadFile a tu web.xml dentro de un <servlet> y <servlet-mapping>
  #7 (permalink)  
Antiguo 24/11/2011, 12:14
Avatar de yamiblancoc  
Fecha de Ingreso: agosto-2011
Mensajes: 103
Antigüedad: 12 años, 8 meses
Puntos: 4
Respuesta: El recurso requerido.

ok ya va que yo no entiendo mucho JAVA; este es el uploadfile.java

Código JAVA:
Ver original
  1. package ve.gob.fii.web;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6. import java.util.Iterator;
  7. import java.util.List;
  8.  
  9. import javax.servlet.ServletException;
  10. import javax.servlet.http.HttpServlet;
  11. import javax.servlet.http.HttpServletRequest;
  12. import javax.servlet.http.HttpServletResponse;
  13.  
  14. import org.apache.commons.fileupload.DiskFileUpload;
  15. import org.apache.commons.fileupload.FileItem;
  16.      
  17.      
  18.     @SuppressWarnings({ "deprecation", "serial" })
  19.     public class uploadFile extends HttpServlet {
  20.      
  21.        /**
  22.         protected void processRequest(HttpServletRequest request, HttpServletResponse response)
  23.         throws ServletException, IOException {
  24.             response.setContentType("text/html");
  25.             PrintWriter out=response.getWriter();
  26.             System.out.println("<html>");
  27.             System.out.println("<head>");
  28.             System.out.println("<title>Servlet</title>");
  29.             System.out.println("</head>");
  30.             System.out.println("<body>");
  31.        
  32.             System.out.println("Comenzamos procesamiento ficheros");
  33.      
  34.             procesaFicheros(request,out);
  35.      
  36.             System.out.println("</body>");
  37.             System.out.println("</html>");
  38.      
  39.             out.close();
  40.         }
  41.       {
  42.             System.out.println("El error es " + cadena);
  43.         }*/
  44.         void depura(String cadena) {
  45.     }
  46.      public boolean procesaFicheros(HttpServletRequest req, PrintWriter out ) {
  47.          
  48.          try {
  49.                 System.out.print("El numero de ficheros su");
  50.      
  51.                 DiskFileUpload fu = new DiskFileUpload();
  52.      
  53.                 fu.setSizeMax(1024*512); // 512 K
  54.                 System.out.print("El numero de ficheros su");
  55.      
  56.                 depura("Ponemos el tamaño máximo");
  57.                 fu.setSizeThreshold(4096);
  58.      
  59.                 System.out.print("El numero de ficheros su");
  60.                 fu.setRepositoryPath("/tmp");
  61.                 System.out.print("El numero de ficheros su");
  62.      
  63.                 List fileItems=fu.parseRequest(req);
  64.      
  65.                 if(fileItems==null)
  66.                 {
  67.                     System.out.print("El numero de ficheros su");
  68.      
  69.                     depura("La lista es nula");
  70.                     return false;
  71.                 }
  72.      
  73.                 System.out.print("El número de ficheros subidos es: " +  fileItems.size());
  74.      
  75.                Iterator i=fileItems.iterator();
  76.                 FileItem actual=null;
  77.                 //depura("estamos FileItem actual = null;en la iteración");
  78.                 while (i.hasNext())
  79.                 {
  80.                     actual = (FileItem)i.next();
  81.                     String fileName = actual.getName();
  82.                     System.out.println("<br> Nos han subido el fichero: " + fileName);
  83.      
  84.                     File fichero = new File(fileName);
  85.                    File dir = new  File("D:\\PRUEBA\\");
  86.                    File archivo;
  87.  
  88.                    actual.write(fichero);
  89.                    System.out.println( fichero);
  90.                 }
  91.      
  92.             }
  93.             catch(Exception e) {
  94.                 depura("Error de Aplicación " + e.getMessage());
  95.                 return false;
  96.             }
  97.      
  98.             return true;
  99.      }
  100.     }

y este mi web.xml

Código java:
Ver original
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
  3.  
  4.  
  5.  
  6.   <display-name>tilesExample</display-name>
  7.  
  8.   <context-param>
  9.         <param-name>contextConfigLocation</param-name>        
  10.         <param-value>/WEB-INF/dispatcher-servlet.xml,/WEB-INF/dispatcher-conection.xml</param-value>
  11.   </context-param>
  12.  
  13.   <listener>
  14.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  15.   </listener>
  16.  
  17.   <servlet>
  18.         <servlet-name>dispatcher</servlet-name>
  19.         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
  20.         <load-on-startup>1</load-on-startup>
  21.     </servlet>
  22.    
  23.     <servlet-mapping>
  24.         <servlet-name>dispatcher</servlet-name>
  25.         <url-pattern>*.htm</url-pattern>
  26.     </servlet-mapping>
  27.    
  28. <welcome-file-list>
  29.         <welcome-file>redirect.jsp</welcome-file>
  30.     </welcome-file-list>
  31.    
  32.  
  33. </web-app>

tambien tengo un dispatcher-servelt.xml, un dispatcher-conection.xml y un tile-defs.xml
  #8 (permalink)  
Antiguo 24/11/2011, 18:23
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 13 años, 11 meses
Puntos: 5
Respuesta: El recurso requerido.

por ejemplo yo tengo en mi struts , por que lo tuyo es spring ya vi:
algo asi

esto esta en un action

Código PHP:
    public ActionForward subirArchivo(ActionMapping mapping,ActionForm form,
                                      
HttpServletRequest request,HttpServletResponse response ){
         
String forwar null;
         
FileForm fileForm = (FileFormform;
         
FormFile document fileForm.getUploadFile();
         
String nomFile document.getFileName();
         
FileOutputStream outputStream null;
         
String path null;
         
int size 0;
         
TestForm forma null;
          if (
request.getSession().getAttribute("user")==null){
              return 
mapping.findForward("error");
          }
            try{
                 
                 
HttpSession session request.getSession() ;
                 
ServletContext context session.getServletContext();
                 
path context.getRealPath("/archivosCargados/");
                 
size document.getFileSize(); 

                 
File folder = new File(path);
                 if(!
folder.exists()) {
                     
folder.mkdir();
                 }
                 
                 
DataInputStream in = new DataInputStream(document.getInputStream());
                 
byte dataBytes [] = new byte[size];
                 
int byteRead 0;
                 
int totalBytesRead 0;
                 while(
totalBytesRead<size) {
                     
byteRead in.read(dataBytestotalBytesReadsize);
                     
totalBytesRead += byteRead
                 }
                
String saveFile path nomFile;
                
outputStream = new FileOutputStream(saveFile);
                
outputStream.write(dataBytes0size-1);
                
outputStream.flush();
                
outputStream.close();
                
System.out.println("Server path:" +path);
               
                 
forwar "upload";
            }
            catch(
Exception e){
             
e.printStackTrace();
             
forwar "error";
            }
            
finally {
             return 
mapping.findForward(forwar);
            }
                                      
     } 
en el jsp viene algo asi:

Código PHP:
<%@ page contentType="text/html;charsetutf-8"%>
<%@ 
taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%> 
<%@ 
taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ 
taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<
html>
  <
head>
    <
meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    
    <
script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/TestAjax.js'></script>                                    
    <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'></script>
    <script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'></script> 
    <script type='text/javascript'> 
        function hello()
        {
            var name=DWRUtil.getValue("message");
            TestAjax.sayHello(name,function(data){
            DWRUtil.setValue("result",data);         
          });
        }
    
    </script>  
  
<script type="text/javascript" >  

jQuery(document).ready(function(){  
            
       jQuery('a[name=subirArchivo]').click(
          function ()
            {
            alert('aki subir');
            jQuery('#forma').attr("action",'<%=request.getContextPath()%>/muestra.do?showAct=subirArchivo');
            jQuery('#forma').submit();
            });
       
       
    
    });    
</script>    
    
<style type="text/css">

</style>
    <title>test</title>
  </head>
  <body>
  <%  
//    response.setHeader("Cache-Control", "no-cache");
//    response.setHeader("Pragma", "no-cache");
//    response.setHeader("Expires", "Thu, 29 Oct 2000 17:04:19 GMT");
//    response.setContentType("text/html; charset=utf-8");
%>
<html:form action="/muestra.do" styleId="forma" enctype="multipart/form-data">
 <table cellpadding="2" cellspacing="3">
     <tr>
         <td>
            <div>
                <input type="text" name="message" id="message">
                <input type="button" value="Say Hello" onclick="hello();">
                <span id="result">
                </span>
            </div>
        </td>
    </tr>
   
    <tr>
        <td width="25%">
           <html:file property="uploadFile" value="Seleccionar file" size="10" /><br>
        </td>
    </tr>
    <tr>
        <td width="25%">
            
                        <div class="right controles">
                                <a class="button3"  name="subirArchivo" ><bean:message key='boton.upload'/></a>
                                
                                <a  onclick="aprobarDocumentos()"; class="boton-rojo" name="AprobarSeleccionados" id="aprobar"><bean:message key='boton.upload'/></a>
                                <div class="clear"></div>
                    </div><br>
        </td>
    </tr>
    
    
    </table>
     
</html:form>
  </body>
</html> 
Cheers, Hope this helps ...Solo transfiere el archivo de un sitio a otro

Etiquetas: recurso
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:17.