0 Comments

2个Web应用集成问题解决

发布于:2013-04-26  |   作者:广州网站建设  |   已聚集:人围观

2台机器部署了2个Web应用,A应用需要访问B应用的URL。为了保证URL不会让任意用户随便粘贴就可以访问,需要在B应用上加上filter拦截请求,并进行权限校验。A应用的URL给用户看来是一个中间跳转页面的URL。在这个中间页面,添加hidden的value,在B应用的filter端进行value的校验。代码如下:

Html代码

广州网站建设,网站建设,广州网页设计,广州网站设计
  1. <%@ page language="java" contentType="text/html;   
  2.  
  3. charset=UTF-8"  
  4.     pageEncoding="UTF-8"%> 
  5. <html> 
  6.     <head> 
  7.         <title></title> 
  8.         <meta http-equiv="pragma" content="no-cache"> 
  9.         <meta http-equiv="cache-control" content="no-cache"> 
  10.         <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
  11.  
  12.         <script type="text/javascript"> 
  13.         function init(){  
  14.             document.getElementById('myForm').action="http://localhost:8080/ext2.2/Filter.jsp" 
  15.             document.getElementById('myForm').submit();  
  16.         }  
  17.         </script> 
  18.     </head> 
  19.     <body onload="init()"> 
  20.         <form method="post" id="myForm"> 
  21.             <input type="hidden" name="key" id="key" value="MERKTLTTOR"> 
  22.         </form> 
  23.     </body> 
  24. </html> 

Html代码


  1. <%@ page language="java" contentType="text/html;   
  2.  
  3. charset=UTF-8"  
  4.     pageEncoding="UTF-8"%> 
  5. <html> 
  6.     <head> 
  7.         <title></title> 
  8.         <meta http-equiv="pragma" content="no-cache"> 
  9.         <meta http-equiv="cache-control" content="no-cache"> 
  10.         <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 
  11.  
  12.         <script type="text/javascript"> 
  13.         function init (){  
  14.             <%  
  15.             String key=request.getParameter("key");  
  16.             if(!"MERKTLTTOR".equals(key)){  
  17.             %> 
  18.                 alert('不允许访问');  
  19.             <%  
  20.             }  
  21.             %> 
  22.         }  
  23.         </script> 
  24.     </head> 
  25. <body onload="init()"> 
  26.         <form method="post" id="myForm"> 
  27.             <input type="hidden" name="key" id="key" value="MERKTLTTOR"> 
  28.         </form> 
  29.     </body> 
  30. </html> 

这是filter页面,实际中可以是真正的过滤器filter。

中间页面采用post提交,用户在url中看不到提交的hidden。

中间页面的form的action可以用request.getParamter()获取

当然value可以采用一些加密算法进行加密。

广州网站建设,网站建设,广州网页设计,广州网站设计

标签:
飞机