Maruli Maruli - 4 months ago 6x
Java Question

Restlet Reference decoding "#" sign

I have setup a URI as below:

router.attach("/pmap/campaign/{campaign}/staffCat/{staffCat}/isp/{isp}", PMAPResource.class);

In the PMAPResource.class I have the following code:

public Representation represent()
String campaignID = (String) this.getRequestAttributes().get("campaign");
String staffCat = Reference.decode((String) this.getRequestAttributes().get("staffCat"));
String ispID = (String) this.getRequestAttributes().get("isp");

The staffCat field is manual input from user, it can be anything. Some examples are:


It works for most cases until it hits the # sign where it returns
404 Not Found
error. Console dump shows the following

What should I do in order to read the "#" so I can get
as it is?


# has special meaning in a URL. It must be escaped.

There are actually many special characters in URLs, so you should always escape arbitrary text when building a URL in the client.

In this particular case, the correct URL sent by the client would be something like:


Again, this is a problem that needs to be fixed on the client. The server will decode the %23 for you.