Ayuda con upload, ve en que fallo y como soluciono
Este es mi formulario en jsp
<%@page import="java.io.*,java.sql.*, java.util.*" errorPage="error.jsp"%>
<jsp:useBean id="Tem" class="mar.Temas" scope="page"/>
<jsp:setProperty name="Tem" property="*"/>
<jsp:useBean id="CredUsuario" class="mar.CredencialesUsuario" scope="session" />
<%
String Usuario=CredUsuario.getUsuario();
if (Usuario.equals("")){%>
<jsp:forward page="login.jsp"/>
<% }%>
<%
int cod=0, codig=0;
%>
<html>
<head><title>Actualizaciòn de Temas</title></head>
<body bgcolor='#DBE7F3'>
<% out.print(request.getParameter("nomfoto"));
if (request.getParameter("Enviar")==null){
cod=Integer.parseInt(request.getParameter("id"));
%>
<%
Tem.Coneccion();
String[][] Tema=Tem.Seleccionar(Integer.parseInt(request.getParameter("id")));
Tem.Cerrar();
%>
<p align=center><strong><font size="5" face="Arial">ACTUALIZACION DE TEMAS</font></strong></P>
<p align=left><a href='#' onclick='javascript:history.go(-1)' >Regresar</a></P>
<form method="post" action="GuardaTema.jsp" enctype='multipart/form-data' >
<TABLE>
<TR>
<th>TEMA:</th>
<td><input name="indice" type="text" size='80' value='<%= Tema[0][2]%>'></td>
</TR>
<TR>
<th>CONTENIDO:</th>
<td><textarea name="contenido" rows=20 cols='70' ><%= Tema[0][3]%></TEXTAREA></td>
</TR>
<TR>
<th>IMAGEN:</th>
<td><img src="servlet/ImagenMarcelCH?name=<%= Tema[0][0]%>"><br><input name="foto" type="file" ></td>
</TR>
<TR>
<td><input name="Enviar" value='Actualizar' type=submit ></td>
</TR>
<TR>
<td><input name="codigo" type="hidden" value='<%=cod%>'>
<input name="capcodigo" type="hidden" value='<%= Tema[0][1]%>'> </td>
</TR>
</TABLE>
</form>
<%}else{ %>
<jsp:forward page="servlet/uploadFichero"/>
<%cod=Integer.parseInt(request.getParameter("codigo"));
codig=Integer.parseInt(request.getParameter("capcodigo"));
//out.print(request.getParameter("foto"));
try{
Tem.Coneccion();
}catch(ClassNotFoundException e){
System.out.println("Coneccion Fallada:" + e.getMessage());
}catch(SQLException e){
System.out.println("Coneccion Fallada:" + e.getMessage());
}
try{
Tem.Actualizar(cod);
Tem.Cerrar();
}catch(SQLException e){
System.out.println("Insersion Fallada:" + e.getMessage());
}
%>
<%}%>
</body>
</html>
ahora cuando le leo en el servlet no puedo leerlo los campos excepto este <input name="foto" type="file" >.
Ya que necesito leerlos todos los campos y subir al servidor solo la imagen, para asi poder grabarlos en la base de datos
EN ESE PROBLEMA ESTOY. PORFAVOR SO ALGUIEN PUEDE AYUDARME
<%@page import="java.io.*,java.sql.*, java.util.*" errorPage="error.jsp"%>
<jsp:useBean id="Tem" class="mar.Temas" scope="page"/>
<jsp:setProperty name="Tem" property="*"/>
<jsp:useBean id="CredUsuario" class="mar.CredencialesUsuario" scope="session" />
<%
String Usuario=CredUsuario.getUsuario();
if (Usuario.equals("")){%>
<jsp:forward page="login.jsp"/>
<% }%>
<%
int cod=0, codig=0;
%>
<html>
<head><title>Actualizaciòn de Temas</title></head>
<body bgcolor='#DBE7F3'>
<% out.print(request.getParameter("nomfoto"));
if (request.getParameter("Enviar")==null){
cod=Integer.parseInt(request.getParameter("id"));
%>
<%
Tem.Coneccion();
String[][] Tema=Tem.Seleccionar(Integer.parseInt(request.getParameter("id")));
Tem.Cerrar();
%>
<p align=center><strong><font size="5" face="Arial">ACTUALIZACION DE TEMAS</font></strong></P>
<p align=left><a href='#' onclick='javascript:history.go(-1)' >Regresar</a></P>
<form method="post" action="GuardaTema.jsp" enctype='multipart/form-data' >
<TABLE>
<TR>
<th>TEMA:</th>
<td><input name="indice" type="text" size='80' value='<%= Tema[0][2]%>'></td>
</TR>
<TR>
<th>CONTENIDO:</th>
<td><textarea name="contenido" rows=20 cols='70' ><%= Tema[0][3]%></TEXTAREA></td>
</TR>
<TR>
<th>IMAGEN:</th>
<td><img src="servlet/ImagenMarcelCH?name=<%= Tema[0][0]%>"><br><input name="foto" type="file" ></td>
</TR>
<TR>
<td><input name="Enviar" value='Actualizar' type=submit ></td>
</TR>
<TR>
<td><input name="codigo" type="hidden" value='<%=cod%>'>
<input name="capcodigo" type="hidden" value='<%= Tema[0][1]%>'> </td>
</TR>
</TABLE>
</form>
<%}else{ %>
<jsp:forward page="servlet/uploadFichero"/>
<%cod=Integer.parseInt(request.getParameter("codigo"));
codig=Integer.parseInt(request.getParameter("capcodigo"));
//out.print(request.getParameter("foto"));
try{
Tem.Coneccion();
}catch(ClassNotFoundException e){
System.out.println("Coneccion Fallada:" + e.getMessage());
}catch(SQLException e){
System.out.println("Coneccion Fallada:" + e.getMessage());
}
try{
Tem.Actualizar(cod);
Tem.Cerrar();
}catch(SQLException e){
System.out.println("Insersion Fallada:" + e.getMessage());
}
%>
<%}%>
</body>
</html>
ahora cuando le leo en el servlet no puedo leerlo los campos excepto este <input name="foto" type="file" >.
Ya que necesito leerlos todos los campos y subir al servidor solo la imagen, para asi poder grabarlos en la base de datos
EN ESE PROBLEMA ESTOY. PORFAVOR SO ALGUIEN PUEDE AYUDARME
El problema esta en que requestGetParameter("foto") no te funciona porque no retorna un String, el debe suministrar un flujo de bytes con el contenido de la imagen, debes recuperar el request completo como un MultipartRequest y este si te da toda la informacion!!!!
