当前位置:网站首页>JSP how to obtain the path information in the request object?
JSP how to obtain the path information in the request object?
2022-08-02 00:18:00 【qq_25073223】
From:
http://www.java265.com/JavaCourse/202112/2060.html
The following author describes the method of obtaining the absolute path, virtual path and other information in the request object using the example method, as shown below:
Implementation ideas:Example 1: Project name "maomao"getContextPath(): Get the project nameResult: /maomaogetServletPath() Get the full name of the directory where the current page is located/maomao/jsp/test.jspgetRequestURL() gets the IE address bar addressResult: http://localhost:8080/maomao/testgetServletPath() gets the relative addressResult: /maomao/testExample 2: jsp request address: http://127.0.0.1:8080/projectName/test/testSearch.jsp, various paths are obtained as follows:request.getServletPath():/test/testSearch.jsprequest.getContextPath():/projectNamerequest.getRequestURL(): http://127.0.0.1:8080/projectName/test/testSearch.jsprequest.getRemoteAddr():127.0.0.1request.getServletContext():[email protected].getServerPort():8080request.getScheme():httprequest.getServerName():127.0.0.1request.getProtocol(): HTTP/1.1request.getPathInfo():nullrequest.getQueryString():null
边栏推荐
猜你喜欢
Short video seo search optimization main content
面试高频考题解法——栈的压入弹出序列、有效的括号、逆波兰表达式求值
Keepalived 高可用的三种路由方案
Interview high-frequency test questions solution - stack push and pop sequence, effective parentheses, reverse Polish expression evaluation
电机原理动图合集
【HCIP】BGP小型实验(联邦,优化)
解析正则表达式的底层实现原理
一个有些意思的项目--文件夹对比工具(一)
Excel表格数据导入MySQL数据库
How to design a circular queue?Come and learn~
随机推荐
Play NFT summer: this collection of tools is worth collecting
Interview high-frequency test questions solution - stack push and pop sequence, effective parentheses, reverse Polish expression evaluation
【Leetcode】473. Matchsticks to Square
Zadig 面向开发者的自测联调子环境技术方案详解
【加密周报】经济衰退在加息气氛中蔓延 美联储“放手一搏”?盘点上周加密市场发生的重大事件
22. The support vector machine (SVM), gaussian kernel function
background-image使用
els 方块变形判断。
利用“栈”快速计算——逆波兰表达式
【Leetcode】2360. Longest Cycle in a Graph
Detailed explanation of Zadig's self-testing and tuning environment technical solution for developers
An overview of the most useful DeFi tools
async/await 原理及执行顺序分析
短视频SEO搜索运营获客系统功能介绍
contentEditable属性
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
els 长条变形
协作乐高 All In One:DAO工具大全
PHP从txt文件中读取数据的方法
OpenCV DNN blogFromImage() detailed explanation