当前位置:网站首页>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
边栏推荐
猜你喜欢

EasyExcel的简单读取操作

解析正则表达式的底层实现原理

How to get the best power efficiency in Windows 11?

Arduino 基础语法

当奈飞的NFT忘记了Web2的业务安全

不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?

如何发现新的潜力项目?工具推荐

Double queue implementation stack?Dual stack implementation queue?
![[Three sons] C language implements simple three sons](/img/96/c3f6c331cbc6d794dc5381cf176ba7.png)
[Three sons] C language implements simple three sons

回顾历史5次经济衰退时期:这一次可能会有何不同?
随机推荐
【无标题】
【Leetcode】479. Largest Palindrome Product
[Headline] Written test questions - minimum stack
How to design a circular queue?Come and learn~
security CSRF Vulnerability Protection
Study Notes: The Return of Machine Learning
How to get the best power efficiency in Windows 11?
使用 Zadig 交付云原生微服务应用
LeetCode_279_完全平方数
基于相关性变量筛选偏最小二乘回归的多维相关时间序列建模方法
CRS 管理与维护
08-SDRAM: Summary
els 方块边界变形处理
磁盘与文件系统管理
Ansible中的任务执行控制
uni-app项目总结
Unknown CMake command “add_action_files“
2022/08/01 学习笔记 (day21) 泛型和枚举
Cash Ⅱ LeetCode_518_ change
Short video SEO search operation customer acquisition system function introduction