Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Embedded %23 in query string  RSS feed

 
Jay Grant
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An embedded encoded # (number sign character, encoded as %23) in a URL query string truncates the result of a getQueryString() at that point i.e. everything at and beyond the %23 is discarded. Anyone encounter this, and circumvented it? It is circumventable in Javascript via URL = window.location.toString().split("?"), which retrieves the full URL including the query string in its entirety. The full query string can then be accessed at URL[1}. However, Java itself does not similarly return the full URL including the query string with a single call. Grateful for any enlightenment.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll have to give more details. It's unusual for code to have to intervene.
 
Jay Grant
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getQueryString() on:

http://...?beforenumbersign%23afternumbersign

returns only:

beforenumbersign
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The hash mark and everything that follows is not part of the query string. It's used by the client side and is not sent to the server as part of the URL.
 
Jay Grant
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK thanks...was hoping there might be a simple escape/encode to allow it to be passed as data...I'll have to convert/translate it to something else to accomplish that...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It just needs to be properly encoded. How is the URL being generated?

For example, if I try a URL with query string: ?x=aaa&23bbb

I get the expected query string of: x=aaa%23bbb

and the value of x is aaa#bbb

Whatever's generating the URL isn't doing it correctly somehow.
 
Jay Grant
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm...maybe it works in key=value format then...
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works in any case when properly encoded. A query string of ?aaa%23bbb

results in getQueryString() returning: aaa%23bbb

and a request parameter map of (in JSON notation):
{
"aaa#bbb": [""]
}


as expected.
 
Jay Grant
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getQueryString() is being issued in a servlet, so presumably your response re. client/server sides applies...sorry I forgot to include that...
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!