JSP不会生成所有HTML代码

时间:2017-06-22 16:29:27

标签: java apache jsp tomcat7

我有一个较旧的JSP网页,它在apace tomcat 7之前工作得非常好。现在我正在尝试恢复页面,我将它添加到服务器上(使用相同的apache tomcat 7服务器)并且它确实在'不再像以前那样工作了。
比我检查页面上的源代码,我看到在某个随机点,html代码不再被写入。 如果有人可以帮我这个。

html停止的代码:

<!-- Portfolio Modals -->
<!-- Use the modals below to showcase details about your portfolio projects! -->

<!-- Portfolio Modal 1 -->
<%
            for(int i=0; i<seznamID.size(); i++){
                id=seznamID.get(i);
                title=seznamTitle.get(i);
                description=seznamDescription.get(i);
                mainThumbnail=seznamMainThumbnail.get(i);
                investor=seznamInvestor.get(i);
                year=seznamYear.get(i);

        %>
<div class="portfolio-modal modal fade" id="portfolioModal<%=id %>" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="close-modal" data-dismiss="modal">
                <div class="lr">
                    <div class="rl">
                    </div>
                </div>
            </div>
            <div class="container">
                <div class="row">
                    <div class="col-lg-8 col-lg-offset-2">
                        <div class="modal-body">
                            <!-- Project Details Go Here -->
                            <h2><%=title %></h2><br/>

                            <div class="container">
                                <div class="row">
                                    <div class="col-md-4">
                                    <%
                                    String sql4="SELECT name FROM webPage.images WHERE eng_references_ideng_references='"+id+"';";
                                    Class.forName("com.mysql.jdbc.Driver");
                                    Connection con4 = DriverManager.getConnection("jdbc:mysql://path_to_db?useUnicode=true&characterEncoding=UTF-8",
                                            "username", "password");
                                    Statement st4 = con4.createStatement();
                                    ResultSet rs4= st4.executeQuery(sql4);

                                    ArrayList <String>seznamImages=new ArrayList();
                                    String images=null;

                                    while (rs4.next()){
                                        images=rs4.getString("name");
                                        seznamImages.add(images);
                                    }
                                    con4.close();
                                    rs4.close();
                                    st4.close();
                                    %>
                                        <div class="fotorama" data-nav="thumbs" data-width="90%" data-ratio="800/600 " data-loop="true"> 
                                            <a href="img/references/<%=mainThumbnail%>"><img src="img/references/<%=mainThumbnail%>"></a>
                                            <%for (int j=0; j<seznamImages.size();j++){ 
                                            String slika=seznamImages.get(j);
                                            %>
                                            <a href="img/references/<%=slika%>"><img src="img/references/<%=slika%>"></a>
                                            <%} %>
                                        </div>
                                    </div>
                                    <div class="col-md-6">
                                        <p><%=description%></p>
                                        <table class="table">
                                            <tr>
                                                <td>Investor</td>
                                                <td><%=investor %></td>
                                            </tr>
                                            <tr>
                                                <td>implementation</td>
                                                <td><%=year %></td>
                                            </tr>
                                            <tr>
                                            <td>Actions</td>
                                            <td>
                                            <%
                                                String sql3="select a.title , c.title, c.ideng_references from action a inner join action_references b on a.idaction = b.action_idaction inner join eng_references c on b.eng_references_ideng_references  = c.ideng_references where c.ideng_references='"+id+"';";
                                                Connection con3 = DriverManager.getConnection("jdbc:path_to_db?useUnicode=true&characterEncoding=UTF-8",
                                                        "username", "password");
                                                Statement st3 = con3.createStatement();
                                                ResultSet rs3=st3.executeQuery(sql3);

                                                ArrayList <String>seznamAction=new ArrayList();
                                                String action=null;

                                                while(rs3.next()){
                                                    action=rs3.getString("title");
                                                    seznamAction.add(action);
                                                }

                                                con3.close();
                                                st3.close();
                                                rs3.close();
                                                for(int j=0; j<seznamAction.size(); j++){
                                                    action=seznamAction.get(j);
                                                    out.print(action+"<br/>");

                                                }
                                            %>
                                            </td>
                                            </tr>
                                        </table>
                                    </div>

                                </div><br/>
                            <button type="button" class="btn btn-primary center" data-dismiss="modal"><i class="fa fa-times"></i> Close</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

来自网页的源代码:

enter image description here

1 个答案:

答案 0 :(得分:0)

由于代码中的异常而生成HTML停止。

添加:

  Try {

   Catch (Throwable e){e.printStackTrace();}

修改代码并发现问题