public_html jsp显示源代码而不是网页

时间:2018-07-09 02:11:49

标签: java html apache jsp tomcat

我对jsp环境还很陌生,因此无法自行解决很多问题。我客户的网站现在移至Centos linux服务器并安装了tomcat以支持jsp页面。 Tomcat 7.0.88。 Java版本“ 1.7.0_80”

我能够在8080上运行示例应用程序,但是public_html下的代码仅显示源代码。我想tomcat无法将其范围扩展到apache设置,但是由于我不知道要看哪里,所以我无法解决此问题。

请引导我。

index.jsp代码:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import ="java.io.File"%>
<%@ page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@ page import="javax.servlet.http.*" %>
              <%@ include file="dbconn.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
 <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="images/favicon.png" type="image/png" sizes="16x16">
    <meta name="p:domain_verify" content="7a990a9eaa00bc5e44972096c3bb0728"/>
    <meta name="description" content="YOUNG, an advertising agency providing creative, brand strategy, design, media & digital services. We create compelling brand communication that deliver results" />
    <meta name="keywords" content="advertising agency; creative; television commercials; brand development; logo design; web design; advertising creatives" />
    <title>Young - Advertising, Creative, Brand Strategy, Design, Media, Digital</title>
    <meta property="og:type" content="YOUNG" />
    <meta property="og:title" content="YOUNG - Advertising, Creative, Brand Strategy, Design, Media, Digital" />
    <meta property="og:description" content="YOUNG, an advertising agency providing creative, brand strategy, design, media & digital services. We create compelling brand communication that deliver results" />
    <meta property="og:image" content="http://www.weareyoung.in/images/uploads/young-fb.png" />
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:title" content="YOUNG" />
    <meta name="twitter:description" content="YOUNG, an advertising agency providing creative, brand strategy, design, media & digital services. We create compelling brand communication that deliver results" />
    <meta name="twitter:image" content="http://www.weareyoung.in/images/uploads/young-tw.png" />


    <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/hover.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/jssocials.css" rel="stylesheet">    
    <link href="css/helper.css" rel="stylesheet">
    <link href="css/font/css/font-awesome.min.css" rel="stylesheet">
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700" rel="stylesheet" />

</head>
<body>
    <%
                    String h1="";String h2="";String h3="";String h4="";String h5="";String h6="";
                    h1="class=active";
                    int enquiryform=0;
                    %>
        <%@ include file="header.jsp" %>
    <div class="master-container">
        <div class="layout">
            <div class="row ptop2">
                <div class="col-md-6 pright2">
                    <div class="row">
                        <div class="col-md-12">
                          <%  
                            String mlnk=""; String htitle=""; String hdet="";String urllnk="";
                            Statement stmt=conn.createStatement();
                            String seldata="select * from young_home where secid=1";
                            ResultSet rs = stmt.executeQuery(seldata);

                               String strShort1="";
                               String wordsArray1[];
                               int i_foot1=0;
                            while(rs.next())
                            { 
                                htitle = rs.getString("sectitle");
                                hdet = rs.getString("sectext");
                                urllnk = rs.getString("urllink");
                                int wordsToCut1 = 200;
                                wordsArray1 = hdet.split(" ");
                                if(wordsArray1.length > wordsToCut1)
                                {
                                    while(i_foot1 < wordsToCut1)
                                    {
                                        strShort1 += wordsArray1[i_foot1] + " ";
                                        i_foot1++;
                                    }   
                                    strShort1= strShort1+"...";
                                }
                                else
                                {
                                    strShort1= hdet;
                                }
                            }
                            rs.close();
                          %>
                            <div class="brand-content">
                                <div class="bc-area">
                                    <h1><%=htitle%></h1>
                                    <div class="mb0">
                                    <%=strShort1 %>
                                    <a data-toggle="modal" data-target="#brands-text" class="brands-textm"><b>Click here for more</b></a>
                                    </div>
To see <a href="<%=urllnk%>" target="_blank"><b>YOUNG Brochure</b></a> click here
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row ptop2">
                        <div class="col-md-12">
                          <%  
                            String mlnk1=""; String htitle1=""; String hdet1="";String str="";
                            String memsubtitle="";
                            Statement stmt1=conn.createStatement();
                            String seldata1="SELECT * FROM young_casestudy where PKCsID=1";
                            ResultSet rs1 = stmt1.executeQuery(seldata1);

                            while(rs1.next())
                            { 
                                htitle1 = rs1.getString("Casetitle");
                                hdet1 = rs1.getString("CaseDetail");
                                mlnk1 = rs1.getString("SImg");
                                memsubtitle = rs1.getString("Casesubtitle");

                            }
                            rs1.close();

                            /* String strShort2="";
                            if(htitle1 != "")
                            {
                                String hdettitle="";
                                hdettitle = htitle1;

                                 String wordsArray2[];
                                 int i_foot2=0;
                                 int wordsToCut1 = 2;
                                 wordsArray2 = hdettitle.split(" ");
                                 if(wordsArray2.length >= wordsToCut1)
                                 {
                                     while(i_foot2< wordsToCut1)
                                     {
                                         if(strShort2 == "")
                                         {
                                             strShort2 = wordsArray2[i_foot2];
                                         }
                                         else
                                         {
                                             strShort2 = strShort2 + "" + wordsArray2[i_foot2];
                                         }
                                         i_foot2++;
                                     }   
                                 }
                                 else
                                 {
                                     strShort2= hdettitle;
                                 }
                            } */

                            %>
                             <div class="fig-hover-item height-332">
                                <div class="overlay">
                                    <div class="overlay-color"></div>
                                    <div class="overlay-content big-box">
                                        <p class="subheading">Case study</p>
                                        <h2><%=htitle1%></h2>
                                        <p><%=memsubtitle %></p>
                                        <span class="btn btn-line hvr-bounce-to-bottom">View Case </span>
                                    </div>
                                    <a class="full-link" href="Casestudylndpg.jsp?cid=1"></a>
                                </div>
                                <img src="images/CaseStudy/<%=mlnk1%>" alt="">
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-6 pl0">
                    <div class="row">
                        <div class="col-md-12 banner">
                            <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
                                <ol class="carousel-indicators">
                                    <%  
                    Statement stmt_1=conn.createStatement();
                    String seldata_1="select * from young_home where secid=2";
                    ResultSet rs_1 = stmt_1.executeQuery(seldata_1);
                    int i=0;
                    String actlnk;
                    while(rs_1.next())
                    { 
                        actlnk="";
                        if(i == 0)
                        {
                            actlnk = "active";
                        }
                           %>
                                     <li data-target="#carousel-example-generic" data-slide-to="<%=i%>" class="<%=actlnk%>"></li>
                                           <% i=i+1; } %>
                                </ol>

                                <div class="carousel-inner" role="listbox">
                                   <%  
                    String imgfilenamefull1="";
                    Statement stmt_2=conn.createStatement();
                    String seldata_2="select * from young_home where secid=2";
                    ResultSet rs_2 = stmt_2.executeQuery(seldata_2);
                    int j;
                    j=0;
                    String actlnk1;
                    while(rs_2.next())
                    { 
                        actlnk1="";
                        if(j == 0)
                        {
                            actlnk1 = "active";
                        }

                        imgfilenamefull1 = rs_2.getString("ImgName");
                           %>
                              <div class="item <%=actlnk1%>">
                                        <img src="images/slider/Home/<%=imgfilenamefull1 %>" alt="...">
                                    </div>
                                    <%j= j+1; } %>
                                </div>

                                <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
                                    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
                                    <span class="sr-only">Previous</span>
                                </a>
                                <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
                                    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
                                    <span class="sr-only">Next</span>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="row ptop2">
                                <div class="col-md-6 pright2">
                                    <div class="fig-hover-item height-330">
                                        <div class="overlay">
                                             <%  
                                        String mlnk2=""; String htitle2=""; String hdet2="";String str1="";
                                        String memsubtitle2="";
                                        Statement stmt2=conn.createStatement();
                                        String seldata2="SELECT * FROM young_casestudy where PKCsID=2";
                                        ResultSet rs2 = stmt2.executeQuery(seldata2);

                                        while(rs2.next())
                                        { 
                                            htitle2 = rs2.getString("Casetitle");
                                            hdet2 = rs2.getString("CaseDetail");
                                            mlnk2 = rs2.getString("SImg");
                                            memsubtitle2 = rs2.getString("Casesubtitle");
                                        }
                                        rs2.close();

                                        /* String strShort3="";
                                        if(htitle2 != "")
                                        {
                                            String hdettitle1="";
                                            hdettitle1 = htitle2;

                                             String wordsArray3[];
                                             int i_foot3=0;
                                             int wordsToCut1 = 2;
                                             wordsArray3 = hdettitle1.split(" ");
                                             if(wordsArray3.length >= wordsToCut1)
                                             {
                                                 while(i_foot3< wordsToCut1)
                                                 {
                                                     if(strShort3 == "")
                                                     {
                                                         strShort3 = wordsArray3[i_foot3];
                                                     }
                                                     else
                                                     {
                                                         strShort3 = strShort3 + "" + wordsArray3[i_foot3];
                                                     }
                                                     i_foot3++;
                                                 }   
                                             }
                                             else
                                             {
                                                 strShort3= hdettitle1;
                                             }
                                        }
                                         */
                            %>
                                            <div class="overlay-color"></div>
                                            <div class="overlay-content">
                                                <p class="subheading">Case study</p>
                                                <h2><%=htitle2 %></h2>
                                                <p><%=memsubtitle2 %></p>
                                                <span class="btn btn-line hvr-bounce-to-bottom">View Case </span>
                                            </div>
                                            <a class="full-link" href="Casestudylndpg.jsp?cid=2"></a>
                                        </div>
                                        <img src="images/CaseStudy/<%=mlnk2%>" alt="">
                                    </div>
                                </div>
                                <div class="col-md-6 pl0">
                                    <div class="fig-hover-item height-330">
                                        <div class="overlay">

                                            <div class="overlay-color"></div>
                                            <div class="overlay-content">
                                                <h2>Young Radio One</h2>
                                                <p>Young is Proud to Ride the Mumbai FM Waves on Radio One</p>
                                                <span class="btn btn-line hvr-bounce-to-bottom">View Case </span>
                                            </div>
                                            <a class="full-link" href="young-radio-one.jsp"></a>
                                        </div>
                                        <img src="images/CaseStudy/young-radio-one-creative-430-X-350.jpg" alt="">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
            <div class="row">
                <div class="col-md-12 btn-portfolio">
                    <a href="Work.jsp?wrid=1" class="btn btn-default hvr-bounce-to-bottom btn-portfolio">Browse our portfolio</a>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="yellow-bg">
                        <h1>Our Services</h1>
                        <ul class="services">
                      <%
                      String sname="";
                      Statement psPg=conn.createStatement();
                      String sqlPg="SELECT * FROM young_services";
                      ResultSet rsPg = psPg.executeQuery(sqlPg);
                      while (rsPg.next())
                      {
                          sname = rsPg.getString("Sname");
                      %>
                            <li>
                                <div class="img-block">
                                    <img src="images/<%= rsPg.getString("SImgname")%>" alt="">
                                </div>
                                <h3><%=rsPg.getString("Sname") %></h3>
                                <p><%=rsPg.getString("Fultxt")%></p>
                                <%if (sname.equalsIgnoreCase("Creative")){ %>
                                <a class="btn btn-default hvr-bounce-to-bottom" href="Work.jsp?wrid=1">Detail</a>
                                <%}else if(sname.equalsIgnoreCase("Media")){ %>
                                <a class="btn btn-default hvr-bounce-to-bottom" href="Media.jsp?wrid=1">Detail</a>
                                <%}else if(sname.equalsIgnoreCase("Realty")){ %>
                                <a class="btn btn-default hvr-bounce-to-bottom" href="realty.jsp?rel=1">Detail</a>
                                <%} %>
                            </li>
                     <%} %>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="bg-wood">
                        <h1 class="mt40">Our Client's</h1>
                        <ul class="client">
                              <%  
                    String lnk=""; String imgfilenamefull="";
                    Statement smt=conn.createStatement();
                    String sel_data="select * from young_client where DisplayHome=1 order by orderno limit 12";
                    ResultSet rs_sel = smt.executeQuery(sel_data);

                    while(rs_sel.next())
                    { 
                        lnk = rs_sel.getString("ClientLnk");
                        imgfilenamefull = rs_sel.getString("ClientImg");
                    %>
                            <li>
                                <a href="<%=lnk%>"><img src="images/Client/<%=imgfilenamefull %>" alt="">
                                </a>
                            </li>
                            <%} %>
                        </ul>
                          <div class="col-md-12 btn-portfolio pt30 pb0">
                            <div class="row hc-btns">
                                <div class="col-md-6 tar"><a href="clients.jsp" class="btn btn-default hvr-bounce-to-bottom btn-portfolio">Browse Clients</a></div>
                                <div class="col-md-6 tal"><a href="clients.jsp#testimonials" class="btn btn-default hvr-bounce-to-bottom btn-portfolio">Browse testimonials</a></div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

    <%@ include file="Footer.jsp" %>

        </div>
    </div>

  <!-- Modal -->
    <div class="modal fade" id="brands-text" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                    </button>
                    <h4 class="modal-title" id="myModalLabel">CREATING BRANDS.  BUILDING EQUITY.</h4>
                </div>
                <div class="modal-body">
                                    <%=hdet %>
                                    To see our online brochure please click <a href="<%=urllnk%>"><b>YOUNG Brochure</b></a>
                </div>
                <div class="modal-footer">
                    <a class="btn btn-default hvr-bounce-to-bottom" data-dismiss="modal">Close</a>
                </div>
            </div>
        </div>
    </div>

    <script src="js/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/jssocials.min.js"></script>
    <script src="js/custom.js"></script>
    <script src="js/customvalidate.js"></script>
    <script src="js/jquery.cookie.js"></script>
</body>
</html>

WEB-INF / web.xml

<?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
      <display-name>Young</display-name>
      <context-param>
        <param-name>uploadDirectory</param-name>
        <param-value>D:\YoungWebsite\Young\WebContent</param-value>
      </context-param>
      <servlet>
        <description></description>
        <display-name>LoginServlet</display-name>
        <servlet-name>LoginServlet</servlet-name>
        <servlet-class>code.youngjava.LoginServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>LoginServlet</servlet-name>
        <url-pattern>/LoginServlet</url-pattern>
      </servlet-mapping>
      <servlet>
        <description></description>
        <display-name>LogOutServlet</display-name>
        <servlet-name>LogOutServlet</servlet-name>
        <servlet-class>code.youngjava.LogOutServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>LogOutServlet</servlet-name>
        <url-pattern>/LogOutServlet</url-pattern>
      </servlet-mapping>
      <servlet>
        <description></description>
        <display-name>JsonServlet</display-name>
        <servlet-name>JsonServlet</servlet-name>
        <servlet-class>code.youngjava.JsonServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>JsonServlet</servlet-name>
        <url-pattern>/JsonServlet</url-pattern>
      </servlet-mapping>
      <servlet>
        <description></description>
        <display-name>EmailSendingServlet</display-name>
        <servlet-name>EmailSendingServlet</servlet-name>
        <servlet-class>code.youngjava.EmailSendingServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>EmailSendingServlet</servlet-name>
        <url-pattern>/EmailSendingServlet</url-pattern>
      </servlet-mapping>
      <!--  SMTP settings 
      --> 

    <!-- <servlet>
            <servlet-name>ConnectorServlet</servlet-name>
            <servlet-class>com.ckfinder.connector.ConnectorServlet</servlet-class>
            <init-param>
                <param-name>XMLConfig</param-name>
                <param-value>config.xml</param-value>
            </init-param>
            <init-param>
                <param-name>debug</param-name>
                <param-value>false</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>ConnectorServlet</servlet-name>
            <url-pattern>
                ckfinder/connector/ConnectorServlet.java
                /ckfinder/java/com/ckfinder/connector/ConnectorServlet.java  
                    /ckfinder/core/connector/java/connector.java
            </url-pattern>
        </servlet-mapping>
        <filter>
            <filter-name>FileUploadFilter</filter-name>
            <filter-class>com.ckfinder.connector.FileUploadFilter</filter-class>
                    <init-param>
                        <param-name>sessionCookieName</param-name>
                        <param-value>JSESSIONID</param-value>
                    </init-param>
                    <init-param>
                        <param-name>sessionParameterName</param-name>
                        <param-value>jsessionid</param-value>
                    </init-param>
        </filter>
        <filter-mapping>
            <filter-name>FileUploadFilter</filter-name>
            <url-pattern>
                WebContent/ckfinder/core/connector/java/connector.java
                /ckfinder/java/com/ckfinder/connector/ConnectorServlet.java 
                /ckfinder/core/connector/java/connector.java
             </url-pattern>
        </filter-mapping> -->
    </web-app>

编辑:我尝试过这种尝试,希望能发生一些魔术:/ usr / local / cpanel / scripts / addservlets2 --domain = weareyoung.in,但是缺少“ addservlets2”,所以我尝试了“ addservlets”,但是腻子只是冻结了,什么也没有发生。

0 个答案:

没有答案