Java HttpCookie getPath() Method

The getPath() method of HttpCookie class is used to return the path on the server for which the browser return the cookie. The cookie will be visible to all the sub paths on the given server.

Syntax

Parameter

N.A.

Return

The above method is used to return a string which specifies the path which contains the servlet name. For e.g. - /catalog

Example 1

Test it Now

Output:

The path is given as: 189.144.22.5/user/index.html

Example 2

Test it Now

Output:

The first path is given as: 189.144.22.5/user/index1.html
The second path is given as: 145.132.19.6/client/index2.html

Example 3

Test it Now

Output:

The path is given as: null




Latest Courses