0

I am having a RESTful Java Web Service that accepts a long string with '#' in between.

When I am trying to send the string to the method while calling, the string is getting split on '#' and I can retrieve the [0] value alone.

Before sending the message is intact, but after using this..

req.open("GET","https://localhost:8443/registername/resources/registerName/"+"My#Name", true);
req.send();

is the problem.

These are the first few lines in the Web Service...

@GET
@Path("/{message}")
public String validateName(@PathParam("message") String message) throws Exception{
    System.out.println(message);
...}

And, it displays "My" alone.

Can anyone please help me on why this is happening? Thanks!

kausal_malladi
  • 1,542
  • 3
  • 14
  • 30

3 Answers3

3

In URLs, a # sign indicates a "named anchor," something that local javascript, and it is not sent to the remote server, so when you have the URL:

https://localhost:8443/registername/resources/registerName/My#Name

Name isn't sent to the server. You need to use a different split character.

See What is it when a link has a pound "#" sign in it or http://www.hypergurl.com/anchors.html for more information.

Community
  • 1
  • 1
Jakob Weisblat
  • 7,450
  • 9
  • 37
  • 65
2

HTTP post or get will not read anything after #, Do a URLEncode before doing POST or GET.

NullPointerException
  • 3,732
  • 5
  • 28
  • 62
1

I don't think the part after the # is sent up with the GET request.

mconlin
  • 8,169
  • 5
  • 31
  • 37