The javax.servlet.http.HttpServletRequest.getRequestURI method returns a String representing the part of the request URL that identifies the resource being requested. This includes the context path but does not include any query string parameters.
Example 1: Suppose a user accesses the URL `https://www.example.com/myapp/mypage.jsp?param1=abc¶m2=123`. The getRequestURI method returns `/myapp/mypage.jsp` as a String.
Example 2: Suppose a user accesses the URL `https://www.example.com/myapp/`. The getRequestURI method returns `/myapp/` as a String.
Code examples:
// Importing the required package import javax.servlet.http.HttpServletRequest;
// Getting the request URI HttpServletRequest request = (HttpServletRequest) servletRequest; String requestURI = request.getRequestURI();
// Printing the request URI System.out.println("Request URI: " + requestURI);
Package Library: javax.servlet.http
Java HttpServletRequest.getRequestURI - 30 examples found. These are the top rated real world Java examples of javax.servlet.http.HttpServletRequest.getRequestURI extracted from open source projects. You can rate examples to help us improve the quality of examples.