Java获取服务器网址
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获取服务器网址的更多相关文章
- java获取服务器路径
java获取服务器一些信息的方法(服务器地址/相对路径/端口/项目名字 request.getServletContext().getRealPath("/") 获取项目所在服务 ...
- java获取服务器IP地址及MAC地址的方法
这篇文章主要介绍了java编程实现获取机器IP地址及MAC地址的方法,实例分析了Java分别针对单网卡及多网卡的情况下获取服务器IP地址与MAC地址的相关技巧,需要的朋友可以参考下 本文实例讲述了 ...
- java获取服务器基本信息
实现步骤: (1)创建servlet BrowserServer (2)调用HttpServletRequest对象的getServerName()方法获取服务器名称 (3)调用HttpServlet ...
- JAVA获取服务器路径的方法
1.在JSF环境中获取到ServletContext: 1 2 ServletContext sc = (ServletContext)FacesContext. getCurrent ...
- java获取服务器的ip和地址
HttpServletRequest httpRequest=(HttpServletRequest)request; String strBackUrl = "http://" ...
- java获取服务器一些信息的方法
request.getServletContext().getRealPath("/") 获取项目所在服务器的全路径,如:D:\Program Files\apache-tomca ...
- JAVA 获取指定网址的IP地址 实例
如今买票是一大难事,在高峰时段 打开12306网站,慢的像蜗牛,想到以前用修改hosts文件来登录Google(Hosts是一个没有扩展名的系统文件,可以用记事本等工具打开,其作用就是将一些常用的网址 ...
- java 获取服务器时间同步本地计算机时间
http://hi.baidu.com/captives/item/25c8b80170a9b0ccf45ba6f8 ————————————————————————————————————————— ...
- java获取服务器所有信息
package com.sinosoft.outher.listener; import java.net.InetAddress;import java.net.UnknownHostExcepti ...
随机推荐
- 在 github 上获取源码
比如访问: https://github.com/alifellod/NWebGather 可以找到下面的源码获取方式. 在github开源项目的页面上可以找到上图的三个获取源码方式. 使用git的网 ...
- 文件大boss
1.write() 写命令 f=open("a2.txt",'w',encoding='utf-8') f.write() f.close() 2.closed 判断是否是关闭 ...
- JAVA堆外内存
JVM可以使用的内存分外2种:堆内存和堆外内存. 堆内存完全由JVM负责分配和释放,如果程序没有缺陷代码导致内存泄露,那么就不会遇到java.lang.OutOfMemoryError这个错误. 使用 ...
- 命令别名alias设置
<转:http://vbird.dic.ksu.edu.tw/linux_basic/0320bash_3.php> 命令别名配置: alias, unalias 命令别名是一个很有趣的东 ...
- Js 设置class,兼容ie,火狐的方式
var trs = document.getElementsByTagName("tr"); trs[0].className="color2"; //设置c ...
- 转:Tomcat安装配置及站点说明
原文地址:http://www.cnblogs.com/Johness/archive/2012/07/20/2600937.html 1.首先是Tomcat的获取和安装. 获取当然得上Apache的 ...
- Spark Streaming、HDFS结合Spark JDBC External DataSouces处理案例
场景:使用Spark Streaming接收HDFS上的文件数据与关系型数据库中的表进行相关的查询操作: 使用技术:Spark Streaming + Spark JDBC External Data ...
- UnixBench测试
安装: 1. UnixBench from version 5.1 on has both system and graphics tests. If you want to use the g ...
- The first day!!!
我的小院子开通啦,开始记录自己的学习历程,加油!!!
- Log4Net日志的配置
<configuration> <configSections> <section name="log4net" type="log ...