当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Statement执行update语句
How does JSP use request to get the real IP of the current visitor?
单片机遥控开关系统设计(结构原理、电路、程序)
146. LRU 缓存
基于数据驱动的变电站巡检机器人自抗扰控制
els 长条变形
els 方块变形
Excel导入和导出
玩转NFT夏季:这份工具宝典值得收藏
How to solve the error when mysql8 installs make
Win11内存管理错误怎么办?
ES中SQL查询详解
632. 最小区间
els 方块边界变形处理
[Headline] Written test questions - minimum stack
基于超参数自动寻优的工控网络入侵检测
Arduino 基础语法
图解LeetCode——1161. 最大层内元素和(难度:中等)
JSP Taglib指令具有什么功能呢?
GIF making - very simple one-click animation tool