File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to put '&' in request query string

 
Atul Samnerkar
Ranch Hand
Posts: 44
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to encode the URL. The HttpServletResponse has encodeURL() method .Ampersand is %38 if I remember correctly.
 
Manjusha Muraleedas
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64188
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On the server use URLEncoder.encode(). On the client encodeURIComponent() oe encodeURI().
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manjusha Muraleedas wrote:
I googled for "URL Encoding Technique" . but i didnt get any useful link.

Seriously?
 
Hebert Coelho
Ranch Hand
Posts: 754
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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...:-)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic