Encode url with JSDK 1.3

J

Jacob Welsh

I have an url as a String that I want to encode before I use it for my call
to a webserver . The problem is that I'm bound to use JSDK 1.3.1 so the
URLEncoder.encode(String) only provides one type of encoding (UTF-8 ?). Are
there any other solutions to encode the url to different encodings?
 
J

Jon Caldwell

In JDK 1.4, they introduced a encode(String,String) method which
accepts an character encoding name as the second parameter.
 
J

Jacob Welsh

In JDK 1.4, they introduced a encode(String,String) method which
accepts an character encoding name as the second parameter.

I know! But as I said, I must use JDK 1.3. There is no possibility for me to
use JDK 1.4 in my project.
 
J

Jon Caldwell

That can be frustrating. I have one project I am bound to 1.3, and
another I must use 1.1.8 (stupid antequated AIX releases!).

The underlying implementation of URLEncoder.encode wraps a
OutputStreamWriter which wraps around a ByteArrayOutputStream. They use
the 1-parameter constructor of OutputStreamWriter, which accepts the
OutputStream. URLEncoder is a very simple class, you may want to resort
to rewriting your own implementation of it.

Also, I believe that Jakarta Commons runs on 1.3. Check out the Commons
Codec package. http://jakarta.apache.org/commons/codec/.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,190
Latest member
Martindap

Latest Threads

Top