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. <s:select>下拉框是空白的解决办法

    首先,定义了一个Department的JavaBean对象如下 DAO.java 在一个Action类Employee.java中将depts放入requestMap中 最后,在index.jsp里定 ...

  2. Google Tensorflow 源码编译(一):Protobuf<v3.0.0-alpha-3>

    这几天终于把tensorflow安装上了,中间遇到过不少的问题,这里记录下来.供大家想源码安装的参考. 安装环境:POWER8处理器,Docker容器Ubuntu14.04镜像. Build Prot ...

  3. 黄聪: Bootstrap之Form表单验证神器: BootstrapValidator(转)

    前言:做Web开发的我们,表单验证是再常见不过的需求了.友好的错误提示能增加用户体验.博主搜索bootstrap表单验证,搜到的结果大部分都是文中的主题:bootstrapvalidator.今天就来 ...

  4. 小调网 经典电影 豆瓣评分 tampermonkey脚本

    // ==UserScript== // @name 小调网 // @namespace http://tampermonkey.net/ // @version 0.1 // @descriptio ...

  5. Redis部分数据结构方法小结

    package com.practice.util; import java.util.HashMap; import java.util.List; import java.util.Map; im ...

  6. Java 大数运算

    import java.util.*; import java.math.*; public class Main{ public static void main(String args[]){ S ...

  7. 配置SQL Server 2005 远程连接(转)

    方法如下:  一.为 SQL Server 2005 启用远程连接1. 单击"开始",依次选择"程序"."Microsoft SQL Server 2 ...

  8. 甲状腺癌怎样早发现 可B超检查

    2013-12-13 14:40:00.0 本文来源:人民网 点击参与跟帖 原标题:健康之道:甲状腺癌怎样早发现 摘要:甲状腺癌怎样早发现呢?隐早期以甲状腺结节的方式存在,且以匿方式生长,可能在人们偶 ...

  9. mybatis oracle insert 返回新增的主键值

    <insert id="insertVmsTemplatePlayItem" parameterType="VmsTemplatePlayItem"> ...

  10. 45. Scramble String

    Scramble String Given a string s1, we may represent it as a binary tree by partitioning it to two no ...