Java Reference
In-Depth Information
L ISTING 5.4 Continued
/**
* connect to the license server
*/
public String connect() {
HttpConnection c = null;
InputStream is = null;
OutputStream os = null;
StringBuffer message = new StringBuffer();
try {
c = (HttpConnection)Connector.open(createURL());
String outcome = c.getHeaderField(“outcome”);
//in case of no connection return null
if (outcome==null) {
return null;
}
if (outcome.equals(“true”))
successfullyRegistered = true;
// open the InputStream
is = c.openInputStream();
// read the servlet output
int ch;
while ((ch = is.read()) != -1) {
message.append((char)ch);
}
} catch (Exception exc) {
System.out.println(“connect() “+exc);
}
return message.toString();
}
/**
* process commands
*/
public void commandAction(Command c, Displayable d) {
if (c.getCommandType()==Command.OK) {
String s = “”;
Gauge gau = new Gauge(“Checking License”,false,8,0);
Form frm = new Form(“Please Wait.. “,new Item[] {gau});
gau.setValue(2);
Display.getDisplay(midlet).setCurrent(frm);
licenseId= idTextField.getString();
passwd = pwdTextField.getString();
5
Search WWH ::




Custom Search