• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Tomcat 6 : RequestParameter value gets cut off at hash (#) character

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

This is probably an easy one for you.

In my servlet, I am trying to capture the value of a parameter:

paramName=key
paramValue=val#ue

However, as you can see, the value contains a '#' char in the string, and, when i call request.getParameter("key"), all I get is the string "val"

How can I capture the entire string "val#ue"?

Thanks in advance.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The "#" character has a specific meaning in URLs. So if you want to treat it as an ordinary character, you have to URL-escape it.

However it's not your servlet which has to do the URL-escaping, it's whoever generated the request in the first place. Perhaps somebody clicked on a link which you generated, which had that "#" character in it? If that's the case then you should URL-escape the parameter values when you generate that link. Anyway the first thing to do is to find out where that request came from and how the URL was generated there.
 
Edwin Rivera
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote: Anyway the first thing to do is to find out where that request came from and how the URL was generated there.



Therein lies the issue.

The request originates from Facebook.

This issue is happening in the servlet that is defined as the redirect_uri in our facebook oauth dialog. When a user successfully authenticates, facebook looks up the request_uri (my servlet), and issues a GET request.

The string with the '#' in it, is what is contained in the code=xxx key/value pair of the request. I need this code to then grab an access_token for subsequent Oauth calls.

Actually, *anything* after the '#' (uri fragment) is ignored by the request, even additional key/value pairs.

I'll try taking this up with FB directly if there's no easy workaround via Tomcat and the HttpRequest object.

Thanks for the quick reply!

 
Edwin Rivera
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like I'm not alone:

https://developers.facebook.com/blog/post/552/

and

http://bugs.developers.facebook.net/show_bug.cgi?id=20504

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic