
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);
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


0