This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

problem with ampersand(&) in passing values through URL  RSS feed

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
This is the problem I face some times when using get method to pass
values from one page to other.If the values im trying to pass has some ampersands(&)
(e.g) say <a href="http://localhost/file2.jsp?value=aa<b rel="nofollow">&&&&&</b>aaa" target="_blank">http://localhost/file2.jsp?value=aa&&&&&aaa
purposely I have added some ampersands for value and im sure this will end up in problem
Is there any way to overcome this???
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
u make that value as String.
I mean.
String s = a&&&a;
and then pass in the url as http://url?value=s;
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i think this is not possible. because every query string key-value pairse
is parsed using &.

thanks,
velmurugan veerappan
 
Author and ninkuma
Marshal
Posts: 66805
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course it is possible, and simply making it a string will do nothing for you.
All your URL values should be URL-encoded. You can easily accomplish this with the help of the java.net.URLEncoder class. This will encode special characters (such as the &) to a form that will not confuse the format of the URL.
[ April 01, 2004: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bear,
Can you provide an exapmle or some snippet of the code for using
this encoder class.
On Google...there are lots....
A basic snippet would solve the purpose
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66805
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's not much to it. For the example value in the original post:

will produce:

which is URL-safe.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!