This week's book giveaway is in the iOS forum.
We're giving away four copies of Classic Computer Science Problems in Swift and have David Kopec on-line!
See this thread for details.
Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Christian Wolf

Greenhorn
+ Follow
since Dec 15, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Christian Wolf

Stupido. Why easy, if it works complicated, too?
Just use InputStreamWriter and OutputStreamWriter. They take care for encoding. You write 2byte-characters and you get 2byte-characters. That's it.
Christian Stupido
14 years ago
I received a image higher my screen, and I don't know how to scroll this image.
Use translate(0,y) to set the physical pixel point (0,0) to logical point (0,y). Then the canvas will start to draw at (nonexisting) physical point (0,-y) and you see the lower part of the image. Use the cursor keys to modify translation.
Christian Wolf
14 years ago
Hello.
The issue I mentioned in my mail above has been solved. No problem anymore.
Short explaination: the SJIS (shift-jis) charset I am using includes ASCII-7 as subset. As this is an encoding, it is taken care, that a valid 1-byte character is not prefix of a 2-byte-character. So the problem with the & as delimiter is actually no problem at all.
Then I was able to send data to the server but the received data looked strange. Finally I found out. People adapt examples for their purpose and so did I. In Sun WTK 2.0, the demos MIDlet contained code for HTTP connection. They used code like

to append a new byte that was read from the stream to a StringBuffer. I made the error then that I simply converted this Stringbuffer to String by calling StringBuffer.toString() and wondered why I do not see the Japanese characters that I did input in the MIDlet. Then I realized by looking at verbose debugging output that two single bytes do not merge automatically to one two-byte character.
Solution is to convert the StringBuffer containing the byte representation of the string into a pure byte-array (first exporting the StringBuffer to char-array, then copying char[] to byte[]). This byte array can be used as argument for new String(byte[]) which automatically uses a default encoding, SJIS in my case. Result is new string containing all characters that I also inserted. This is kind of expensive but it seems to be neccessary.
Christian Wolf
14 years ago
Hello.
In my own application, I need to send user input to the server. The application is intended for the Japanese market, so I want to send data that is encoded in SJIS. I started with a pure English application, and sending POST data with application/x-www-form-urlencoded content-type worked quite fine. But with SJIS encoded strings, this looks not that fine anymore.
input=��� �&id=500
So my question: does this work at all with the mentioned content-type or have I to use multipart/form-data where I can specify an encoding for each part? At least the server application seems to recognize the different parameters in the example body string above. But I fear that the SJIS encoded string contains a & that is then treated as delimiter.
I do not use OutputStreamWriter at the momen that could take care of encoding but just write the strings from the TextFields into the output stream.
Christian Wolf
14 years ago
Is there a method to check if an SQL-server is running?
*g* Sure. The same method as with every server. Try to connect to it. Either it fails (timeout) or you get a response from the server.
Christian Wolf
I would like send several HTTP request/response without have to open a new connection.
The feature you want to use is called Keep-Alive. There are some problems with it that might prevent you of using this HTTP header. It seems to me that HttpConnection on MIDP offers only HTTP/1.0. The older protocol has some problems with Kee-Alive when connecting to proxies. And a proxy might be in place in your network.
Also, the API itself makes it difficult for you to flexible make use of Keep-Alive (if supported at all) as you specify the target URL in the initial (HttpConnection)Connector.open command. So I could only imagine that you can send multiple requests to the same URL again. You will recognize support or not very easy. When trying to send this header, you might get an exception "no resource". This indicates that this header is not supported, so you have to use single connections for each request.
Keep-Alive
Christian Wolf
14 years ago
Because I would like integrate payment's system. For this, my server needs identify the client who use the midlet.
The same problem have many servers who need to authenticate their users so that data access is restricted only to valid users. This is not so much a problem of the J2ME or mobile applications, but of the communication layer. Some approaches exist:
  • Extend the HttpConnection class in that way, that it transparently can process cookies using an RMS. These cookies are then sent with each request to the server, in that way allowing the server to identify users.
  • Let the user choose a username/password that you transmit using hashes as a parameter with each request. Comparison of the hashes verifies identity.
  • Use the subscriber ID that is included in the HTTP header by the WAP gateway. This subscriber ID is supposed to be unique for each single mobile phone. But take care: this is unsafe and can easily be forged.


  • I think there are some more ideas that I forgot right now but others might add them.
    Christian Wolf
    14 years ago
    Much better than using Strings is, according to a famous book here ;-), using StringBuffers. They are not as memory consuming as String objects. But their usage is limited. If you need to do a lot of work with the strings (cut, search), then the multiple conversions from StringBuffer to String and vice versa will cost both memory and CPU cycles.
    Christian Wolf
    14 years ago
    Hello.
    I tried to preverify a class where I have jdk1.4 installed in my computer. It shows an error as "Error preverifying class Howdy: Class loading error:Bad major version number". Kindly help me to solve this problem
    I am not quite sure where your problem comes from but the usual way of making a JAR from your source code is the following:

    tmpclasses-folder and output-folder are used to place compiled classes and verified classes into. Take care to include the midpapi-archive so that both the compiler and the preverifier know what you want to do.
    Christian Wolf
    14 years ago
    Hello.
    So I would appreciate if anyone could advise me what I require to update a table in the database from entries made into a MIDlet.
    You want to send data from the MIDlet to a server application, e.g. a servlet. You have to use HttpConnection to connect to the servlet. You use the POST method that is also commonly used when sending data in a form shown in a web browser. If you just need to send some strings, you can use the content-type "application/x-www-form-urlencoded". You have then to format the message in the body as following :
    var1=value1[&var2=value2[&var3=value3[..]]]
    The Sun Wireless Tool Kit 2 comes with the MIDP API documentation. Look at javax.microedition.io.HttpConnection for an example how an HTTP request is sent.
    Christian Wolf
    14 years ago
    Wow, I have not really imagined that *I* might win the book. So many people and diskcussions in here. Thank you very much. (although I should have had it three months earlier, my project is over in seven weeks ;-)
    Christian Wolf
    14 years ago
    And wonder, does MIDP allow one to process images taken by camera phones ? Does MIDP have JNI capabilities ?
    MIDP does not offer access to the mobile phone's data folder where the images are stored. You need to use an API extension supported by a specific vendor. I think this is what you mean by JNI. Native methods are not supported.
    Christian Wolf
    14 years ago

    Do u mean that class is something like a long value inside and a string value to the output? It will need more processing... So is it like there is a trade-off between processing time and memory location?


    Yes, that's what I mean. It needs slightly more processing, of course, than just calculating pure integer. But if you need to work with floats then you have to make something like that on your own. Memory is not the big problem with this.
    Christian Wolf
    14 years ago

    Do u mean "a decimal point", instead of "a comma"? So that it will become like a decimal notation, since MIDP does not contain such Float or Double class...


    You are right, of course, I mean "decimal point", the delimiter character between trunc(c) and (c-trunc(c)) *g* It's called "comma" in my language.
    So in result you get a class being able to make fix point calculations based on strings as arguments and longs as internal representation of fix point numbers.
    Christian Wolf
    14 years ago
    Floating point operations are expensive. Therefore the MIDP does not include Float and Double classes and math operations for these classes.
    You can emulate floating point by calculating with very big long types. For example, if you need a precision of 0.000001 then multiply all your arguments with 1000000, make your calculations based on Integers, make a string from the result and then insert a comma at the correct position. The resulting string is then the floating point result of your calculation. If you wrap this into a class, you might have a pseudo Float class that you can use for your program itself
    Christian Wolf
    [ January 20, 2004: Message edited by: Christian Wolf ]
    14 years ago