aspose file tools*
The moose likes Servlets and the fly likes Sending text+ pics Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sending text+ pics" Watch "Sending text+ pics" New topic
Author

Sending text+ pics

Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Hello poeple,
I need some advice. I want to send small articles with pics to a mobile phone. I don't want to send the text with a link to the pic, coz with the latency of wireless networks, it takes really a long to connect and fetch the image.. I am thinking of sending text and at the end a picture, no mime no encoding, after the image tag or whatever delimitor, the rest of the bytes will all be for the image.. I am thinking of making an image out of all the articles images, and easilly cut them at the client side since they all have the same width/hieght ??
Will this work out? any ideas? Is there a way around? force the web server to keep the connection?
Any help will be appreciated.
Thanks a lot.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
Does your client device even have a display API that allows for a message containing mixed text and image data? Are you writing code for both the client and the server?
Bill
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

Originally posted by Tonny Tssagovic:
Hello poeple,
Will this work out? any ideas? Is there a way around? force the web server to keep the connection?
Any help will be appreciated.
Thanks a lot.

HTTP 1.1 has keep-alive connection, but it is still a *stateless* protocal. So you can't do this.
I have done wireless deivce programming way back in year 200-2001; and they didn't have any persitance mechanism back then as far as I can remember. Things must have changed rapudly since then...What sort of image format you'd be using for your mobile devices?
- Manish
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Thanks for ur replies guys!
I use PNG format supported by J2me clients. and yes I am also making the client's code, and will make a custom Canvas that can show both text and image.. Any thoughts?
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
Seems to me you have two decisions to make:
1. How to tell when the text info stops and the image info starts.
2. How to transmit the image info.
For 1 - you could use a marker string like multipart mail does or you could start your text with a character count.
For 2 - the big question is binary versus encoded binary - if your server side is sending a character stream, which involves character translation with a writer, you will have to encode the image - base64 is the most efficient. If your server side is sending a byte stream you should be able to send the binary image directly.
Bill
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Thanks for the reply William
Well, I am probably going to send binary data, since I don't want to have a base 64 decoder at the client side... But are there any problems with sending international text (like the scandinavian �� and so on) in a binary stream? How about the HTTP protocol content type, I have it set to an image now since I am sending only an image, and I have another set to text to send only text.. now I want to have both, no probs with that?? for the delimiter I will just use the something like IMAGE tag or so, since my text is not going to contain such a tag.. and when I reach it I would not care about tags any longer since I would know that according to my protocol, the rest of the stream is a single Image..
Any hel�p will be appreciated.
PS: Others are very welcome to come with IDEAs..
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
If you want the international character capability I think you are going to be creating a character stream with a writer - that means you are going to need to send the image in characters which means encoding. A base64 decoder can be really compact, especially in your case where you completely control both sides and can eliminate special cases.
If you are writing the entire client you can use any HTTP content type you like - it does not affect transmission, only clients like a browser. You might even use a custom header to give the length of the text block.
Bill
Tonny Tssagovic
Ranch Hand

Joined: Dec 30, 2003
Posts: 226
Thanks again William
Well so if I have internatinal text, I must use a charecter stream ?? there is no way around ? Coz it seems to me, 64 encoding will slow my app down and increase its already big size.. Maybe downloading the text /the images one at once will be better..
Any ideas???
Any input is very much appreciated.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12805
    
    5
I'm no expert on the handling of international character sets in typical phones, so I'll pass on that - maybe the J2ME forum can help you there.
Base64 takes 4 bytes to encode 3, so it is not a big deal. Decoding is likely to be fast compared to phone transmission speed or to the time for a second request/response cycle.
Bill
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending text+ pics