从jsp页面我必须返回xml数据。
我从数据库中获取一条记录并显示在Jsp中。我必须在xml中返回一个显示记录。我必须在jsp中同时显示并同时返回xml中的记录。
我已经完成了一个显示过程,并在xml中返回:
<%
String selectsql = null;
DBConnection DBCon = null;
Connection Con = null;
String maprule = null;
PreparedStatement pstm = null;
ResultSet resultSet = null;
String snomedid = request.getParameter("snomedcode");
String snomedname = request.getParameter("snomednames");
try {
DBCon = new DBConnection();
Con = DBCon.getConnection();
selectsql = "SELECT referencedComponentId,sctName,mapTarget,icdName,mapRule,refid FROM snomedicd10map WHERE referencedComponentId=? or sctName=? ";
pstm = Con.prepareStatement(selectsql);
pstm.setString(1, snomedid);
pstm.setString(2, snomedname);
resultSet = pstm.executeQuery();
%>
<h2 align="center">
<font><strong>SNOMED CT TO ICD 10 </strong></font>
</h2>
<div style='min-height: 40px'>
<table id="tblMain" width="100%" class='table1' border=0
cellpadding='5' cellspacing='0' style='topmargin: -5px'>
<tr>
<td colspan='4' style='text-align: right;'>
<!-- <input type="button" value="Back" onclick="goback();" style="background-color: #3399ff;color:#ffffff" /> -->
<button onclick="goBack()" style="background-color: #3399ff;color:#ffffff">Back</button>
</td>
</tr>
<tr class='headerText' style='height: 25px'>
<td class='tdcellblue' style='width: 10%'>SNOMED</td>
<td class='tdcellblue' style='width: 40%'>SNOMED Name</td>
<td class='tdcellblue' style='width: 10%'>ICD-10</td>
<td class='tdcellblue' style='width: 40%'>ICD Name</td>
</tr>
<%
while (resultSet.next()) {
//String maprule = null;
maprule = (resultSet.getString("mapRule"));
if (maprule.matches("OTHERWISE TRUE")
|| maprule.matches("TRUE")) {
%>
<tr>
<td><%=resultSet.getString("referencedComponentId")%></td>
<td><%=resultSet.getString("sctName")%></td>
<td><%=resultSet.getString("mapTarget")%></td>
<td><%=resultSet.getString("icdName")%></td>
</tr>
<%
}
}
%>
</table>
</div>
<%
if(request.getParameter("hiderefineproblem")==null && maprule.matches("OTHERWISE TRUE")){ %>
<input type="button" value="Refine Problem" onclick="return showHide();" style="background-color: #3399ff;color:#ffffff;" />
<%}%>
<div id="showHideDiv" style="display: none;">
<p>Would one of the following diagnoses apply? Choose the most
specific one:</p>
<FORM ACTION="snomedMapping.jsp#newres" METHOD="POST">
<%
pstm = Con.prepareStatement(selectsql);
pstm.setString(1, snomedid);
pstm.setString(2, snomedname);
resultSet = pstm.executeQuery();
boolean bSubmit=false;
int refid=0;
String[] pipe=null;
while (resultSet.next()) {
refid=resultSet.getInt("refid");
pipe= resultSet.getString("mapRule").split("\\|");
if (pipe.length > 1){
bSubmit=true;
%>
<input type="radio" id="radioList" value="<%=refid%>" name="refId"/>
<tr><%=pipe[1]%></tr>
<br />
<%
}
}
%>
<%if(bSubmit){%>
<input type="hidden" name='hiderefineproblem' value='yes'/>
<INPUT TYPE="SUBMIT" value="Submit" style="background-color: #3399ff;color:#ffffff;">
<%}%>
</FORM>
</div>
<script>
function showHide() {
var ele = document.getElementById("showHideDiv")
if (ele.style.display == "block") {
ele.style.display = "none";
} else {
ele.style.display = "block";
}
}
/* function goback(){
window.location.href='/mobiledoc/jsp/catalog/xml/migration/snomedMapping/snomedIndex.jsp';
} */
function goBack() {
window.history.back();
}
</script>
<h2 align="center">
<font><strong></strong></font>
</h2>
<div style='min-height: 40px' id="newres">
<!-- <table id="tblMain" width="100%" class='table1' border=0
cellpadding='5' cellspacing='0' style='topmargin: -5px'>
<tr class='headerText' style='height: 25px'>
<td class='tdcellblue' style='width: 10%'>SNOMED</td>
<td class='tdcellblue' style='width: 40%'>SNOMED Name</td>
<td class='tdcellblue' style='width: 10%'>ICD-10</td>
<td class='tdcellblue' style='width: 40%'>ICD Name</td>
</tr> -->
<table>
<%
String str=request.getParameter("refId");
if(str.length()>0){
refid=Integer.parseInt(str);
//resultSet=Root.EcwCloseResultSet(resultSet);
//pstm=Root.EcwClosePreparedStatement(pstm);
selectsql = "SELECT * FROM snomedicd10map WHERE refid=?";
pstm = pstm = Con.prepareStatement(selectsql);
pstm.setInt(1,refid);
resultSet = pstm.executeQuery();
while (resultSet.next()) {
%>
<tr>
<td colspan='2' style='font-weight:bold;'>SNOMED</td>
</tr>
<tr>
<td><%=resultSet.getString("referencedComponentId")%> </td>
<td><%=resultSet.getString("sctName")%></td>
</tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr></tr>
<tr>
<td colspan='2' style='font-weight:bold;'>Target ICD</td>
</tr>
<tr>
<td><%=resultSet.getString("mapTarget")%> </td>
<td><%=resultSet.getString("icdName")%></td>
</tr>
<%
}
}
%>
</table>
</div>
<% }
如何实施?我需要再创建一个页面或同一页面。
答案 0 :(得分:0)
您只需返回XML文本,而不是从JSP返回HTML文本。
提供的代码具有HTML标记和JSP代码,用于创建HTML文档结构和内容。
JSP的XML版本将具有XML标记和JSP代码,以创建XML文档结构和内容。