Its great your code is working for you.
Just to categorize a few of the options available.
1) If a MIDlet makes a request to the server, its always better to add a property to the request like screen width and screen height. This way the server can read the HTTP headers of the request and determine what sort of content to send out.
2)A combination of User Agent and/or HTTP_X_WAP_PROFILE (or HTTP_PROFILE) headers can be used by the server to determine the screen dimensions of the mobile device.