Ver Mensaje Individual
  #3 (permalink)  
Antiguo 07/05/2009, 13:16
Avatar de fbirrer
fbirrer
 
Fecha de Ingreso: enero-2006
Ubicación: Santiago de Chile
Mensajes: 329
Antigüedad: 18 años, 3 meses
Puntos: 0
Respuesta: problema con applets... no entiendo porque

ESTE ES EL CÓDIGO

Código:
public boolean procesaFicheros(HttpServletRequest req) {
		
		String path 	= getServletContext().getRealPath("\\"); 
		
		ParameterFetcher parameter 	= new ParameterFetcher(req);
 
		Escritorio 		e = new Escritorio();
		try {
			String rutaUpload = pa.getDirectorioUploadArchivos() + "\\fotos_usuarios";
			logger.debug("RUTA DONDE SE CREARAN LAS CARPETAS PARA CADA proyecto --> [" + rutaUpload + "]");
			
            
			DiskFileUpload fu = new DiskFileUpload();
			
			// crea carpeta						
			//String newFolderPath = rutaUpload;						
			File f = new File(rutaUpload);
			f.mkdirs();
			String carpetaFinal = rutaUpload;  //+"\\" ;
						
			logger.debug("RUTA FINAL DONDE SE GUARDARA EL ARCHIVO "+carpetaFinal);											
			// maximo numero de bytes
			//fu.setSizeMax(-1); // 80 KB
			
			////// //logger.info("PONEMOS EL TAMAÑO MAXIMO DEL ARCHIVO --> [80KB]");
			// tamaño por encima del cual los ficheros son escritos directamente en disco
			fu.setSizeThreshold(4096);
			// directorio en el que se escribirán los ficheros con tamaño superior al soportado en memoria
			fu.setRepositoryPath(carpetaFinal);

			// ordenamos procesar los ficheros
			List fileItems = fu.parseRequest(req);
												
			if (fileItems == null) {
				logger.error("LA LISTA ES NULA [NO VIENEN ARCHIVOS]");
				return false;
			}
						
			Iterator i = fileItems.iterator();
			FileItem actual = null;									
			String idProyecto = parameter.getString("RUT","");
			String tipoAdjunto = "";						
            String mensaje = parameter.getString("MENSA","");
            logger.debug("mensaje --> [" + mensaje + "]");
			// Iteramos por cada fichero
			while (i.hasNext()) {
				actual = (FileItem) i.next();
							
				if(actual.isFormField()){//campos de formulario normales no tipo file 
				////// //logger.info("CAMPOS DE FORMULARIO "+ actual.getFieldName());
									
					if(actual.getFieldName().equals("RUT")){					
						idProyecto = actual.getString();
					}
					
				}
				
				else{//procesamos solo los campos de tipo file
				
					String fileName = actual.getName();
										

					//tamaño del archivo
					long tamano = actual.getSize();
					////// //logger.info("TAMAÑO DEL ARCHIVO "+tamano);
						
					//Nombre del campo
					String nombrecampo = actual.getFieldName();
					////// //logger.info("EL NOMBRE DEL CAMPO ES --> ["+ nombrecampo + "]");
					
					// construimos un objeto file para recuperar el trayecto completo
					File fichero = new File(fileName);
					
					
					// nos quedamos solo con el nombre y descartamos el path
					//fichero = new File(carpetaFinal, fichero.getName().trim());
					String dirName = rutaUpload;//+idProyecto;
					//File dir = new File(dirName);
					//dir.mkdirs();
					
					fichero = new File(dirName+"\\", fichero.getName().trim());
					////// //logger.info("pasa por acaa " + fileName);
					////// //logger.info("pasa por acaa " + fileName.substring(fileName.lastIndexOf(".")));
					String sExtension = fileName.substring(fileName.lastIndexOf("."));
					String sNombre = idProyecto;
					System.err.println("EL NOMBRE DEL ARCHIVO ES -->" + rutaUpload+"\\"+fichero.getName().trim() + "");
				
					if(tamano > 307200){
					}
					// escribimos el fichero colgando del nuevo path								
					if(!(actual.getName().equals("")) && (tamano <= 5242880) ){
						actual.write(fichero);
						////// //logger.info("ESCRIBE EL FICHEROOOOOOOOO " + dirName+"\\" + sNombre + sExtension);
						File fichero2 = new File(dirName+"\\",sNombre + sExtension);
						fichero2.delete();
						fichero.renameTo(fichero2);
						//////// //logger.info("fichero-->>" + fichero);
						e.actualizarFoto(sNombre,fichero2.getName());
					} 
					else{
						logger.error("EL CAMPO "+ actual.getFieldName()+" ESTA VACIO");					
					}																
				  }
		   }
		} catch (Exception er) {
			 logger.error(er.getMessage());
			return false;
		}
		
		
	return true;
	}


	public void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {			
		processRequest(req, resp);
		//resp.sendRedirect("escritorio/MainPracticas.jsp");	
	}



Lo que aparece en negrita son las lineas que debe retornar los valores.

La primera linea me retornar bien, la segunda ya no me retorna.


en la pagina web estan de la siguiente forma:

Código:
<BODY>
<form id="upload" name="upload" action="../UploadServlet" method="post" enctype="multipart/form-data" onsubmit="return valida()">
  <table width="434"  border="0" cellspacing="1" cellpadding="0">
    <tr>
      <td width="20" align="right">&nbsp;</td>
      <td>&nbsp;</td>
   	  <TD>&nbsp;<input value="<%=GLOBAL_USUARIOCONECTADO%>" name="RUT" ID="RUT" type="hidden">
	  			<input value="<%=GLOBAL_USUARIOCONECTADO%>" name="MENSA"  id="MENSA" type="hidden">
		 </TD>
    </tr>
    <tr>
      <td width="20" align="center"></td>
      <td align="center">Seleccione un Archivo</td>
      <td align="left"><input name="Adjunto" type="file" class="normalbox" id="Adjunto" size="40" /></td>
    </tr>
    <tr>
      <td width="20" align="center">&nbsp;</td>
      <td colspan="2" align="center"><a href="javascript:valida();"><img src="../img/guardar.PNG" width="68" height="29" border="0" onclick="Javascript:Regresar(1);"  onmouseover="mano(this);" /></a>        <!--|Cancelar--><img src="../img/cancelar.png" width="68" height="29" onmouseover="mano(this);" onclick="Javascript:parent.parent.GB_hide();" /> </td>
    </tr>
  </table>
  <BR>
</FORM></BODY>
Y no logro entender porque no me rescata el valor.

Estuve haciendo pruebas, y este es un servlet que me funcionaba y lo modifique, para ver si esto solucionaba el problema. Pero el problema me sigue dando.

Estoy usando websphere con db2 como gestor de base de datos.

gracias por tu ayuda


pd: vi tu foto y estoy sin comentarios
__________________
Desde Santiago de Chile
Grupo Universite
Información sobre los Institutos Chilenos de Educación
www.universite.cl