ugg
2012年3月24日星期六
Vibram 5 Fingers Shoes
referer 实现防盗链
request_referer.java :
package cn.request;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;//referer防盗链public class request_referer extends HttpServlet {public void doGet(HttpServletRequest request,
Beats By Dre Sale
, HttpServletResponse response)throws ServletException,
Monster Beats Solo
, IOException {//设置浏览器以什么编码打开response.setCharacterEncoding("UTF-8");response.setContentType("text/html;UTF-8");String referer = request.getHeader("referer");//获取请求头//判断这个头是否为空,
Lady Gaga Heartbeats
,或这个头的首地址是否为http://localhost,如果不是则重定向if(referer==null ,
Moncler Outlet
!referer.startsWith("http://localhost") ){response.sendRedirect("/Servlet_1/1.html");return;}String str="你好";response.getWriter().write(str);}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {}}
如果在浏览器地址栏直接链接 :
则获取的请求头为空,因为不是从 链接过来的,属于盗链行为,
Vibram 5 Fingers Shoes
,则重定向
Related articles:
http://betterugg-sales.blogspot.com/2012/03/fiver-finger-shoesthe-empty-room.html
没有评论:
发表评论
较新的博文
较早的博文
主页
订阅:
博文评论 (Atom)
没有评论:
发表评论