scott
scott

Reputation: 974

How to pass parameter value containing parentheses via URL

I am trying to pass a parameter value via the URL and it works for most values unless the value contains parenthesis. I have tried the backslash () to escape them but it doesn't appear to work.

Here is the URL

http://<server>/OpenDocument/opendoc/openDocument.aspx?sViewer=html&sDocName=<DocName>&sType=rpt&promptex-<ParamName>=VALUE_CONTAINING_(PARENTHESIS)

Upvotes: 1

Views: 4283

Answers (2)

scott
scott

Reputation: 974

I discovered that the value can be enclosed in quotes and then URI-escaped.

The URL becomes

http://<server>/OpenDocument/opendoc/openDocument.aspx?sViewer=html&sDocName=<DocName>&sType=rpt&promptex-<ParamName>=URI_ESCAPE("VALUE_CONTAINING_(PARENTHESIS)")

Upvotes: 2

shrub34
shrub34

Reputation: 796

What you are looking for is URL encoding. Parenthesis will not be your only issue. So for the full answer, I recommend looking at the table available http://www.w3schools.com/tags/ref_urlencode.asp

For your specific answer:
( = %28
) = %29

&promptex-=VALUE_CONTAINING_(PARENTHESIS) becomes &promptex-=VALUE_CONTAINING_%28PARENTHESIS%29

This will then be un-encoded by the servlet engine.

Upvotes: 0

Related Questions