StringBuffer url1 = request.getRequestURL();
String tempContextUrl1 = url1.delete(url1.length() - request.getRequestURI().length(), url1.length()).append("/").toString();
System.out.println("------1>"+tempContextUrl1);

StringBuffer url = request.getRequestURL();
String tempContextUrl = url.delete(url.length() - request.getRequestURI().length(), url.length()).append(request.getContextPath()).append("/").toString();
System.out.println("------2>"+tempContextUrl);

System.out.println("------3>"+request.getRemoteHost()+request.getContextPath());

System.out.println("-----ServletPath---" + request.getServletPath());
System.out.println("-----ContextPath---" + request.getContextPath());
System.out.println("-----referer---" + request.getHeader("referer"));
System.out.println("-----host---" + request.getHeader("host"));
System.out.println("-----RequestURI---" + request.getRequestURI());
System.out.println("-----RequestURL---" + request.getRequestURL());
System.out.println("-----ServerName---" + request.getServerName());
System.out.println("-----ServerPort---" + request.getServerPort());
String realPath1 = "http://"+ request.getServerName()+ ":"+ request.getServerPort()+ request.getContextPath()+ request.getServletPath().substring(0,request.getServletPath().lastIndexOf("/") + 1);
System.out.println("web URL 路径:" + realPath1);

http://10.5.14.66:8101/f1print/exceltemp/001/BarCodePrint.pdf
------1>http://localhost:8080/
------2>http://localhost:8080/yxlis/
------3>0:0:0:0:0:0:0:1/yxlis
-----ServletPath---/case/LLBarcodePrintSave.jsp
-----ContextPath---/yxlis
-----referer---http://localhost:8080/yxlis/case/LLBarcodePrintMain.jsp
-----host---localhost:8080
-----RequestURI---/yxlis/case/LLBarcodePrintSave.jsp
-----RequestURL---http://localhost:8080/yxlis/case/LLBarcodePrintSave.jsp
-----ServerName---localhost
-----ServerPort---8080
web URL 路径:http://localhost:8080/yxlis/case/

Java获取服务器网址的更多相关文章

  1. java获取服务器路径

    java获取服务器一些信息的方法(服务器地址/相对路径/端口/项目名字 request.getServletContext().getRealPath("/")  获取项目所在服务 ...

  2. java获取服务器IP地址及MAC地址的方法

    这篇文章主要介绍了java编程实现获取机器IP地址及MAC地址的方法,实例分析了Java分别针对单网卡及多网卡的情况下获取服务器IP地址与MAC地址的相关技巧,需要的朋友可以参考下   本文实例讲述了 ...

  3. java获取服务器基本信息

    实现步骤: (1)创建servlet BrowserServer (2)调用HttpServletRequest对象的getServerName()方法获取服务器名称 (3)调用HttpServlet ...

  4. JAVA获取服务器路径的方法

    1.在JSF环境中获取到ServletContext: 1 2 ServletContext sc = (ServletContext)FacesContext.         getCurrent ...

  5. java获取服务器的ip和地址

    HttpServletRequest httpRequest=(HttpServletRequest)request; String strBackUrl = "http://" ...

  6. java获取服务器一些信息的方法

    request.getServletContext().getRealPath("/") 获取项目所在服务器的全路径,如:D:\Program Files\apache-tomca ...

  7. JAVA 获取指定网址的IP地址 实例

    如今买票是一大难事,在高峰时段 打开12306网站,慢的像蜗牛,想到以前用修改hosts文件来登录Google(Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址 ...

  8. java 获取服务器时间同步本地计算机时间

    http://hi.baidu.com/captives/item/25c8b80170a9b0ccf45ba6f8 ————————————————————————————————————————— ...

  9. java获取服务器所有信息

    package com.sinosoft.outher.listener; import java.net.InetAddress;import java.net.UnknownHostExcepti ...

随机推荐

  1. jquery datatables双击,获取行号。

    function dbClickDatatables(rows) { $("#@(Perfix)tbData tbody tr").dblclick(function(e){ de ...

  2. HA(High available)-Keepalived高可用性集群(双机热备)单点实验-菜鸟入门级

    HA(High available)-Keepalived高可用性集群   Keepalived 是一个基于VRRP虚拟路由冗余协议来实现的WEB 服务高可用方案,虚拟路由冗余协议 (Virtual ...

  3. javascript性能优化总结一(转载人家)

    一直在学习javascript,也有看过<犀利开发Jquery内核详解与实践>,对这本书的评价只有两个字犀利,可能是对javascript理解的还不够透彻异或是自己太笨,更多的是自己不擅于 ...

  4. [家里蹲大学数学杂志]第237期Euler公式的美

    1 Euler 公式 $e^{i\pi}+1=0$ (1) 它把 a.  $e:$ 自然对数的底 $\approx 2. 718281828459$ (数分) b.  $i$: 虚数单位 $=\sqr ...

  5. web.xml 的加载过程

    初始化过程: 在启动Web项目时,容器(比如Tomcat)会读web.xml配置文件中的两个节点<listener>和<contex-param>. 接着容器会创建一个Serv ...

  6. python装饰器示例

    https://wiki.python.org/moin/PythonDecoratorLibrary#Property_Definition

  7. 18. Word Ladder && Word Ladder II

    Word Ladder Given two words (start and end), and a dictionary, find the length of shortest transform ...

  8. JQ怎么获取margin-left的值

    var margin =$("#Modules .list").css('marginLeft');

  9. 百度地图api简单使用方法

    百度地图API的使用方法   百度地图API 开始学习百度地图API最简单的方式是看一个简单的示例.以下代码创建了一个520x340大小的地图区域并以天安门作为地图的中心: 1. <html&g ...

  10. C++温习

    string abc; cin >> abc; cin把 空格,制表符,换行符作为终止符,用于提取一个词.如果在abc串中输入的内容是有空格的,流中的内容会被打乱? getline (ci ...