2016-06-23 9 views
-3

jspページから、私はxmlデータを返さなければなりません。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")%>&nbsp;&nbsp;&nbsp;</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")%>&nbsp;&nbsp;&nbsp;</td> 
       <td><%=resultSet.getString("icdName")%></td> 
      </tr> 
      <% 
       } 
       } 
      %> 

     </table> 
    </div> 

<% } 

それを実装する方法は?もう1つのページを作成するか、同じページに作成する必要があります。

+0

あなたの最後の文章はナンセンスです。あなたのスペルはひどいです、私はあなたが文章が大文字小文字から始まる、小学校で学んだことは信じられません。 – peterh

答えて

0

JSPからHTMLテキストを返す代わりに、XMLテキストを返すだけです。

提供されているコードには、HTML文書構造とコンテンツを作成するためのHTMLタグとJSPコードがあります。

JSPのXMLバージョンには、XMLタグとJSPコードがあり、XMLドキュメントの構造とコンテンツを作成します。

+0

はいxmlタグを使用していますが、フロントエンドUIに何も表示されないようにしてください。 –

+0

ブラウザにXMLデータを表示する場合は、ブラウザにそれぞれを表示する方法を伝えるCSSスタイルシートを作成しますXML要素。 – Rob

関連する問題