How to pass array of strings to web page

N

news.rcn.com

I have to pass 2 dimensional arrays of strings to a web page where they will
be displayed in a JTable in an applet. I'm looking for a way to package the
array into a string so that I can send it as an attribute on the
HttpResponse object and then pass to the applet as a param and let the
applet unpackage it.

Is there a conventional way of doing this? Or a different approach? I have
one idea (below) but would appreciate the advice of those more experienced..

I thank you in advance for your suggestions.

Jim Cant

My current thought is to 1. URL encode each string, then 2. concatenate all
the strings of a row using a space as a delimiter, then 3. URL encode the
resulting row representations, then 4. concatenate all the encoded rows
with a delimiting space and then 5.. URL encode the resulting representation
of the entire array and finally 6. attach this as an attribute of the web
page.

On the receiving end, the applet would decode the string.
 
R

Roedy Green

I have to pass 2 dimensional arrays of strings to a web page where they will
be displayed in a JTable in an applet. I'm looking for a way to package the
array into a string so that I can send it as an attribute on the
HttpResponse object and then pass to the applet as a param and let the
applet unpackage it.

consider a serialised object. the advantage is you can send ANYTHING
no matter how hairy and complicated with just a line or two of code.
Your biggest problem is making sure both ends have precisely matching
class files.

Same thing GZIPPED.

That is how I handle it in JDisplay for all the tokenized program
listings.

Your Servlet response is actually an octet-stream. If you dig around
surely you can send raw binary back. Think how an HTTP file download
works.

If you really want a String to send, use base64 or base64u.
See http://mindprod.com/jgloss/armouring.html

Other formats you might consider if you are keen on padding the bottom
lines of bandwidth providers include:

1. CSV see http://mindprod.com/jgloss/csv
one line per row, comma separated decimal number or strings. Actually
not that bad for compactness IF the numbers are small.

2. XML pad every field with a pair of 50 character <tag></tag>. See
http://mindprod.com/jgloss/xml.html

3. DER see http://mindprod.com/jgloss/der.html, not necessary unless
talking to non-java.

4. a DataOutputStream. Start with some counts of what's coming, then
let her rip in big-endian binary.
 

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

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top