Author
Special charecters in URL
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
Hi, I need to pass special charecters in a querystring when I click on a hyperlink. charecters like #, ^, spaces.. how to do it. please help. Thanks, Neeraj.
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1334
Hi there, If you find the hex value of the characters you need to pass in, you can use those. the hexadecimal value for a space is 20, and in a URL you can encode this as %20 the caret is %5E the pound character is %23 I'm sure some good references should come up if you google "url encoding" or "url hex encoding"
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
java.net.URLEncoder can do this for you.
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
Hi, Thanks for the help. but we are using jdk1.4 in our project. so looking for a different solution. thanks, Neeraj.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35258
posted Mar 03, 2008 02:10:00
0
but we are using jdk1.4 in our project. so looking for a different solution.
That class has been there since Java 1.0.
Android apps – ImageJ plugins – Java web charts
Neeraj Vij
Ranch Hand
Joined: Nov 25, 2003
Posts: 315
Hi, I was using eclipse 3.0. URLEncoder class gave error. let me check and update. Thanks, Neeraj.
Ben Souther
Sheriff
Joined: Dec 11, 2004
Posts: 13410
Follow the link I posted to that API page. Notice that there is a deprecated version of encode and a newer version that takes two arguments (which has been there since version 1.4). Maybe you were using the deprecated version?
subject: Special charecters in URL