jsp获取服务端的访问信息

 

  •  获取服务端访问信息   
    public static String getUrl(HttpServletRequest request){      
        String url = "";  
          
        if(request != null){  
            String scheme       = request.getScheme();  
            String host         = request.getLocalAddr();  
            int post        = request.getLocalPort();  
            String contextPath  = request.getContextPath();  
                      
                      
            url = scheme + "://" + host + ":" + String.valueOf(post) + "/" + contextPath + "/";   
        }  
        return url;   
    }  




posted @ 2014-05-29 08:49  wala-wo  阅读(238)  评论(0编辑  收藏  举报