• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

How to put '&' in request query string

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

We are facing problem when we have '&' in our query string. For example http://somehost/somepage.jsp?key1=value1&key2=A&B.

Here key2 value is A&B but because & is a separator for query string, we only get A as value.

We cannot really use POST here because this is a hyperlink and not a form submit.

How can I fix this so that I can correctly get values in the target page of hyperlink on server side (somepage.jsp).

-Regards
Atul
 
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to encode the URL. The HttpServletResponse has encodeURL() method .Ampersand is %38 if I remember correctly.
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please post the address of any site/resource explaining this encoding technique?

I googled for "URL Encoding Technique" . but i didnt get any useful link.
 
Sheriff
Posts: 67754
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
On the server use URLEncoder.encode(). On the client encodeURIComponent() oe encodeURI().
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Manjusha Muraleedas wrote:
I googled for "URL Encoding Technique" . but i didnt get any useful link.


Seriously?
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

John Todd wrote:

Manjusha Muraleedas wrote:
I googled for "URL Encoding Technique" . but i didnt get any useful link.


Seriously?



Maybe he checked just the first link... O.o

Dude, i did that research and i found tons of links....

Go there and be happy.
 
Manjusha Muraleedas
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for wasting your time...i didnt had any idea about it... I am new to servlet world and just started studying the basics...

Thank you Bear Bibeault for the help...:-)
reply
    Bookmark Topic Watch Topic
  • New Topic