Java - setAttribute

 
Vista:
sin imagen de perfil

setAttribute

Publicado por Adrian (11 intervenciones) el 06/04/2007 04:51:05
hola a todos :
tengo el siguiente problema tengo un jsp que llama a un servlet el cual hace un select en la base de datos y me devuelve el resultado pero tengo el problema que algunos campos los muestra y otros no a ver si me pueden ayudar ... les paso el codigo. por ejemplo el BookId lo muestra bien pero el campo description no

gracias

Adrian

codigo jsp

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="fontBold">Book Id</td>
<td ><input class="regularfont" type="text" name="BookId" value="<%= request.getAttribute("BookId")== null ? "" :request.getAttribute("BookId") %>"></td>
</tr>
<tr>
<td class="fontBold">Name</td>
<td><input class="regularfont" type="text" name="Name" value="<%= request.getAttribute("Name")== null ? "" :request.getAttribute("Name") %>"></td>
</tr>
<tr>
<td class="fontBold">Description</td>
<td><input class="regularfont" type="text" name="Description" value="<%= request.getAttribute("Description")== null ? "" :request.getAttribute("Description") %>"></td>
</tr>
<tr>

Servlet

String sql = "SELECT BookId, Name, Description, " +
" AuthorId, Published, Price, " +
" SpecialPrice ,Language CategorieId, " +
" ImgSmall, ImgBig" +
" FROM Books " +
" WHERE BookId = " + LoadBookId;

ResultSet res = stmt.executeQuery(sql);

if (res.next()){
Name = res.getString("Name");
}

stmt.close();

request.setAttribute("BookId", LoadBookId);
request.setAttribute ("Name", Name);
request.setAttribute ("Description", Description) ;
request.setAttribute ("AuthorId",AuthorId);
request.setAttribute ("Published",Published);
request.setAttribute ("Price",Price);
request.setAttribute ("SpecialPrice",SpecialPrice);
request.setAttribute ("Language",Language);
request.setAttribute ("CategorieId",CategorieId);
request.setAttribute ("ImgSmall",ImgSmall);
request.setAttribute ("ImgBig",ImgBig);

redispacher(request, response);
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:setAttribute

Publicado por camus (240 intervenciones) el 06/04/2007 19:22:37
Creo que seria mejor idea que llenaras un bean y ese ben lo guardes en el request y despues con jstl o bien con escriptles recuperes con los get los valores.

saludos
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar