首页 > 编程 > JSP > 正文

jsp防盗链

2019-11-18 16:37:15
字体:
来源:转载
供稿:网友

index.jsp

-----------------------------

<html>
  <head><title>Simple jsp page</title></head>
  <body>Place your content here

  here is index jsp
    get header info
  <a href="a.jsp">a.jsp</a>
  </body>
</html>

 

------------------------------

a.jsp页面
通过判断 referer, 判断你从哪里来。

<html>
  <head><title>Simple jsp page</title></head>
  <body>Place your content here

  here is a. jsp
    get header info
  <%=request.getHeader("Referer")%>
  <%if(null == request.getHeader("Referer") || request.getHeader("Referer").indexOf("yourdomain.com") < 0){%>
     做人要厚道
  <%}else{%>
  合法访问
  <%}%>
  </body>
</html>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表