2016-07-01 19 views
1

で働いていない私は私のindex.htmlページにforgotpassword.jspへのリンクを与えたが、私はそれを変更することを決めたいつかの後、私は新しいHTMLファイルを作成しforgotpassword.htmlボディはファイルの両方で似ていますが、画像がforgotpassword.jspに示されているが、 forgotpassword.htmlにはありません。 forgotpassword.jspはさらにpass.jspに行き、私も同じことをしてpass.htmlを作成しました。同じことが起こっていますpass.jspは画像を表示していますが、pass.htmlは表示されません。誰かがなぜこれが起こっているのか教えてもらえますか? となっており、何か不足しているか間違っているかどうかを確認してください。背景画像は、HTML

index.htmlを

<!DOCTYPE html> 
<html> 
<head> 
    <title>Login Page</title> 
    <meta charset="UTF-8"/> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
    <style> 
     header { 
      background-color:lightsteelblue; 
      color:white; 
      text-align:center; 
      padding:5px; 
     } 
     nav { 
      line-height:30px; 
      height:300px; 
      width:100px; 
      float:left; 
      padding:5px; 
     } 
     section { 
      width:600px; 
      float:right; 
      padding:220px; 
     } 
     footer { 
      background-color:black; 
      color:white; 
      clear:both; 
      float:bottom; 
      text-align:center; 
      padding:5px;         
     } 
    </style> 
</head> 
<body style="background-color: lightsteelblue">   
    <header> 
     <canvas id="myCanvas" width="500" height="100" style="border:2px solid black; background-color:burlywood "> 
      Your browser does not support the HTML5 canvas tag.</canvas> 

     <script> 
      var c = document.getElementById("myCanvas"); 
      var ctx = c.getContext("2d"); 
      ctx.font = "45px Arial"; 
      ctx.strokeText("File Tracking System", 50, 50); 

     </script> 
    </header> 
    <a href="forgotpass.jsp">Forgot Your Password</a> 
    <section> 
     <form action="LoginServlet" method="post">    
      Username: <input type="text" name="user"/> 
      <br /> 
      Password: <input type="password" name="pwd"/> 
      <br /> 
      <input type="submit" value="Login"/> 

     </form> 
     <img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/> 
    </section> 
    <footer>Copyright 2016 NSIC. All right reserved.</footer>   
</body> 
</html> 

forgotpass.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%> 
<!DOCTYPE html> 
<html> 
<head> 
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
    <title>Forgot Password Page</title> 
    <style> 
     header { 
      background-color:teal; 
      color:white; 
      text-align:center; 
      padding:5px; 
     } 
     nav { 
      line-height:30px; 
      height:300px; 
      width:120px; 
      float:left; 
      padding:5px; 
     } 
     section { 
      width:800px; 
      float:right; 
      padding:130px; 
     } 
     footer { 
      background-color:black; 
      float:bottom; 
      color:white; 
      clear:both; 
      text-align:center; 
      padding:5px; 
     } 
    </style> 
</head> 
<body style="background-color:lightsteelblue;"> 
    <header><h3>File Tracking System!!</h3> 
     <br> 
    </header> 
    <nav> 
     <form action="forgotServlet" method="POST" > 
      User Name:<input type="text" name="name" value="" size="20" /> 
      Email:<input type="text" name="email" value="" size="20" /> 
      New Password:<input type="text" name="pass1" value="" size="20" /> 
      Repeat Password:<input type="text" name="pass2" value="" size="20" /> 
      <input type="submit" value="submit" name="submit" /> 
     </form> 
    </nav> 
    <section><img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/></section>  
    <footer> 
     Copyright 2016 NSIC. All right reserved.        
    </footer> 
</body></html> 

<!DOCTYPE html> 
<html> 
<head> 
    <title>Forgot Password Page</title> 
    <meta charset="UTF-8"/> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/> 
<style> 
     header { 
      background-color:teal; 
      color:white; 
      text-align:center; 
      padding:5px; 
     } 
     nav { 
      line-height:30px; 
      height:300px; 
      width:120px; 
      float:left; 
      padding:5px; 
     } 
     section { 
      width:800px; 
      float:right; 
      padding:130px; 
     } 
     footer { 
      background-color:black; 
      float:bottom; 
      color:white; 
      clear:both; 
      text-align:center; 
      padding:5px; 
     } 
    </style> 
</head> 
<body style="background-color:lightsteelblue;"> 
    <header><h3>File Tracking System!!</h3> 
     <br> 
    </header> 
    <nav> 
     <form action="forgotServlet" method="POST" > 
      User Name:<input type="text" name="name" value="" size="20" /> 
      Email:<input type="text" name="email" value="" size="20" /> 
      New Password:<input type="text" name="pass1" value="" size="20" /> 
      Repeat Password:<input type="text" name="pass2" value="" size="20" /> 
      <input type="submit" value="submit" name="submit" /> 
     </form> 
    </nav> 
    <section><img src="css/NSIC-logo1.png" width="537" height="267" alt="NSIC-logo1"/></section>  
    <footer> 
     Copyright 2016 NSIC. All right reserved.        
    </footer> 
</body></html> 

forgotpass.htmlこれは私のAuthenticationFilter-

package bean; 

import java.io.IOException; 
import javax.servlet.Filter; 
import javax.servlet.FilterChain; 
import javax.servlet.FilterConfig; 
import javax.servlet.ServletContext; 
import javax.servlet.ServletException; 
import javax.servlet.ServletRequest; 
import javax.servlet.ServletResponse; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import javax.servlet.http.HttpSession; 

public class AuthenticationFilter implements Filter { 

private ServletContext context; 

@Override 
public void init(FilterConfig fConfig) throws ServletException { 
    this.context = fConfig.getServletContext(); 
    this.context.log("AuthenticationFilter initialized"); 
} 

@Override 
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { 

    HttpServletRequest req = (HttpServletRequest) request; 
    HttpServletResponse res = (HttpServletResponse) response; 

    res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate"); // HTTP 1.1. 
    res.setHeader("Pragma", "no-cache"); // HTTP 1.0. 
    res.setDateHeader("Expires", 0); // Proxies. 

    String uri = req.getRequestURI(); 
    this.context.log("Requested Resource::" + uri); 

    HttpSession session = req.getSession(false); 

    if (session == null && !(uri.endsWith("html") || uri.endsWith("LoginServlet") || uri.endsWith("forgotpass.jsp") || uri.endsWith("doesnotexist.jsp") || uri.endsWith("pass.jsp"))) { 
     this.context.log("Unauthorized access request"); 
     res.sendRedirect("index.html"); 
    } else { 
     // pass the request along the filter chain 
     chain.doFilter(request, response); 
    } 

} 

@Override 
public void destroy() { 
    //close any resources here 
} 

} 
です
+0

のみ 'jqueryの/ javaの-Script'を使用してイメージをロードしてみてください。これがあなたに役立つことを望みます。ありがとう –

+0

jspファイルとhtmlファイルの両方に同じフォルダがありますか?このイメージでは、両方のページが指している絶対URLを確認してください。 – Apostolos

+2

デベロッパーツールをチェックインしてください。 – aksappy

答えて

2

編集:chat-conversation-with-rahul問題は本当です。私はそれを解決することができませんでした。

HTMLおよびJSPファイルのファイル構造に問題があります。 @aksappyがコメントした通り、consoleエラーのデベロッパーツール(CTRL+SHIFT+I for chrome)をチェックインしてください。また、<img>タグのsrc属性(デベロッパーツールのhtmljspファイル)を確認してください。

コードは完全に動作しています。

証明

JSP IMAGE JSP IMAGE

HTML IMAGE HTML IMAGE

+0

クロムを使用している場合、リソースが見つかりませんでした。リソースを読み込めませんでした:サーバーが404のステータスで応答しました(21:16 :01:894 | error、network)http:// localhost:8080/test9/css/index.htmlのInternet Explorerで を実行してもエラーが表示されない –

+0

try [this](http://imgur.com/p3Zg1sX) JSPファイルとHTMLファイルの両方に適用されます。開発者ツールの[要素でハイライト表示]タブが表示されているかどうかを確認します。そうでなければ、両方のファイルが同じフォルダにないことを示す問題があります。 WindowsでNetbeansを使用していますか? – rupinderjeet

+0

また、 'index.html'が' css'フォルダの中にあるので、 '' src属性から 'css /'を削除してみてください。 – rupinderjeet