-2

I have a URL which gets formed like below: http://localhost:8080/app/angular/users/#/update/745

When i try to get the URL using request.getRequestURL()I get the URL till http://localhost:8080/app/angular/users. I tried different methods from HTTPServletRequest but none worked.

Can someone please help on this ? I need to understand how can i get full URL, and what is with #.

Rahul
  • 198
  • 4
  • 10

2 Answers2

0

The # is a fragment identifier. You can't get the data after it, it doesn't get sent to the server.

How to get full URL which contains # from HttpServletRequest

To solve this, just don't use the # as a method to pass parameters. Stick with the request parameters such as http://localhost:8080/app/angular/users/update?id=745 and have Spring read in a GET method on the Controller, or use it as a path variable such as http://localhost:8080/app/angular/users/update/745, something you can also retrieve from Spring controllers.

DavidX
  • 1,281
  • 11
  • 16
0

getPathInfo() gives the extra path information after the URI, used to access your Servlet, where as getRequestURI() gives the complete URI.

I would have thought they would be different, given a Servlet must be configured with its own URI pattern in the first place; I don't think I've ever served a Servlet from root (/).

For example if Servlet 'Foo' is mapped to URI '/foo' then I would have thought the URI:

/foo/path/to/resource Would result in:

RequestURI = /foo/path/to/resource and

PathInfo = /path/to/resource

Ahmed Shams
  • 338
  • 1
  • 9