values fetched from database not being displayed
Iam trying to get the values from a table in postgres Database and display in a JSP page. Iam using JSTL to fetch the data. The values in each cell of table are huge i.e some xml content thus iam trying to put that in textarea within a table cell i.e
<body>
<sql:setDataSource driver="org.postgresql.Driver"
url="jdbc:postgresql://x.x.x.x:5432/postgres" user="postgres" password="postgres"/>
<sql:query var="summary" sql="select * from req_resp_summary"&g开发者_运维问答t;
</sql:query>
<br><br><br><br>
<table class="hovertable" align="center">
<h3> Request and Response Summary</h3><br>
<tr>
<th><b>ID</b></th>
<th><b>Name</b></th>
<th><b>Reqest XML</b></th>
<th><b>Respnse XML</b></th>
<th><b>Request TimeStamp</b></th>
<th><b>Responded Time</b></th>
<th><b>Destination</b></th>
<th><b>Status</b></th>
</tr>
<c:forEach var="sum" items="${summary.rows}">
<tr onmouseover="this.style.backgroundColor='#ffff66';" onmouseout="this.style.backgroundColor='#d4e3e5';">
<c:set var="req_xml" value="${sum.request_xml}"/>
<c:set var="res_xml" value="${sum.response_xml}"/>
<%
String response_xml=(String)pageContext.getAttribute("res_xml");
String request_xml=(String)pageContext.getAttribute("req_xml");
%>
<td><c:out value="${sum.request_id}"/></td>
<td><c:out value="${sum.element_name}"/></td>
<!--<td width="20px" height="30px"><c:out value="${sum.request_xml}"/></td>-->
<td><html:textarea property="req_xml" value="<%= request_xml%>" readonly="true" rows="4"></html:textarea> </td>
<!--<td style="text-align: justify; "><c:out value="${sum.response_xml}"/></td>-->
<td><html:textarea property="req_xml" value="<%= request_xml%>" readonly="true" rows="4"></html:textarea> </td>
<td><c:out value="${sum.timestamp}"/></td>
<td><c:out value="${sum.respond_time}"/></td>
<td><c:out value="${sum.destination}"/></td>
<td><c:out value="${sum.status}"/></td>
</tr>
</c:forEach>
</table>
</body>
This is present in for-each loop. The problem is it displays only request_xml string but not response_xml string. It displays one full html table row and other is partial and rest are not being displayed. The first row in jsp page is complete with response string as well.
The other thing is all the values are displayed if i use only tag but i need the string to be included in a textarea.
Any help greatly appreciated. Thanks
Try to use HashMap to collect your String and use it to your textarea.
HashMap x = new HashMap();
HashMap y = new HashMap();
x.add(pageContext.getAttribute("res_xml"));
y.add(pageContext.getAttribute("req_xml"));
精彩评论