几个jsp模块

整理一下小东西,以后用的时候就可以随手拿来了,如果还有jsp的功能模块的话,再加上。
 
一,带线程的计数器。
< %@page  contentType="text/html;charset=gb2312" %> <%!  int count=0;  synchronized void setCount(){   count++;   };   %>      <%    setCount();   out.println("您是第"+count+"个访问本页面的用户");    %>
 
2.网页的重定向
chongdx.jsp
<%@ page contentType="text/html;charset=gb2312" %>

填写姓名:

 
very.jsp
<%@ page contentType="text/html;charset=gb2312" %> <%  String str=null; str=request.getParameter("boy"); if(str==null)  str=""; byte b[]=str.getBytes("ISO-8859-1"); str=new String(b); if(str.equals(""))  response.sendRedirect("chongdx.jsp"); else{  out.println("欢迎来到本网页");  out.println(str);  }
 %>
 
3.防盗链措施
other.jsp在一个网站里,one.jsp 和two.jsp 在另外一个网站里,other.jsp无法访问two页面。
 
other.jsp
<%@ page contentType="text/html;charset=gb2312" %> 这是腾讯的页面,你可以通过点击下面的超链接来下载迅雷里面的东西:
点击下载
 
one.jsp
<%@ page contentType="text/html;charset=gb2312" %> 这是迅雷跳转页面。单击下面的链接来下载迅雷资源:
点击下载
 
two.jsp
<%@ page contentType="text/html;charset=gb2312" %> <%  String mess=request.getHeader("referer"); if(mess==null){  mess="";   response.setStatus(404);  }  if(!(mess.startsWith("http://localhost:8080/lei/xunlei")))   response.sendRedirect("three.jsp");  %>  
 欢迎来下载此资源,您来自:<%=mess %>

转载于:https://www.cnblogs.com/juepei/archive/2013/05/01/3052816.html

你可能感兴趣的:(几个jsp模块)