# HttpServletRequest Path Decoding

The documentation on HttpServletRequest is very poor, and this fills in a critical set of facts that you need to know to write a TomCat application.

The HttpServletRequest object will return the path to the current request with the following methods:

* **`getContextPath`**`()`
* **`getPathInfo`**`()`
* **`getPathTranslated`**`()`
* **`getQueryString`**`()`
* **`getRequestURI`**`()`
* **`getRequestURL`**`()`
* **`getServletPath`**`()`

Imagine you have a tomcat server installed at [**http://server:8080/**](http://server:8080/)

Imagine you install an application in this server at “**myapp**”

That application has a servlet mounted at “**servlet1**”

The user then makes a request:

```
http://server:port/myapp/servlet1/path/file.doc?q1=foo&q2=bar
```

Here is the map of how the various functions decode this:

![](https://1449372731-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LTkdt3HaaBdyfrO73EV%2F-LpcLGu1VAH8CZEzQbl9%2F-LpcLgm9muuFeUXiUMdI%2Fimage.png?alt=media\&token=ea58b654-6f2d-43c3-9c8f-94cf6b43e656)
