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. 字符数组,字符指针,字符串常量,以及sizeof的一些总结

    1.以字符串形式出现的,编译器都会为该字符串自动添加一个\0作为结尾 如在代码中写"abc",编译器帮你存储的是"abc\0". 2.数组的类型是由该数组所存放 ...

  2. Correlation Filter in Visual Tracking系列一:Visual Object Tracking using Adaptive Correlation Filters 论文笔记

    Visual Object Tracking using Adaptive Correlation Filters 一文发表于2010的CVPR上,是笔者所知的第一篇将correlation filt ...

  3. java io流(字节流)复制文件

    java io流(字节流) 复制文件 //复制文件 //使用字节流 //复制文本文件用字符流,复制其它格式文件用字节流 import java.io.*; public class Index{ pu ...

  4. 实现远程连接ACCESS数据库的方法

    使用了TCP/IP,ADO及(需要安装Microsoft 4.0.).分服务器和客户端两部分,可以多用户同时连接.远程连接Access有很多方法,我以前已经比较详细的回答过(见下面所列的5种方法),我 ...

  5. 配置ActiveX控件在网页中下载安装

    先检查客户端浏览器是否安装了ActiveX控件,如果没有安装ActiveX,就需要先给浏览器提示下载并允许安装.否则就直接使用该ActiveX控件.我们可以使用CodeBase来满足我们的要求:下面是 ...

  6. JS中数组Array的用法

    js数组元素的添加和删除一直比较迷惑,今天终于找到详细说明的资料了. var arr = new Array();  // 初始化数组arr[0] = "aaa";arr[1] = ...

  7. 31. Flatten Binary Tree to Linked List

    Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-place. For ex ...

  8. (转自http://www.blogjava.net/moxie/archive/2006/10/20/76375.html)WebWork深入浅出

    (转自http://www.blogjava.net/moxie/archive/2006/10/20/76375.html) WebWork深入浅出 本文发表于<开源大本营> 作者:钱安 ...

  9. Windows窗口自动缩放机制

    通过自动缩放功能,能使在一个计算机上设计的界面在另一个具有不同分辨率或系统字体的计算机上能正常显示.这样窗体及其控件就能通过智能化调整大小以保障在本地电脑和用户电脑上保持一致. 自动缩放的必要性 如果 ...

  10. 慕课网-安卓工程师初养成-6-5 使用循环操作 Java 中的数组

    来源:http://www.imooc.com/code/1531 实际开发中我们经常使用循环控制数组成员的操作.如: 运行结果: 其中,  用于获取数组的长度 需要注意的“小毛病”: 1. 数组下标 ...