|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Need help in solving errors..urgent
Hi,
i need help in solving this J2ME login program of my. I have 8 errors saying "Cannot resolve symbol" Can someone please help me? Thanks..it's urgent.. import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.Connector; import javax.microedition.io.HttpConnection; import javax.microedition.io.StreamConnection; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.InputStream; import java.io.IOException; import java.io.OutputStream; publicclass LoginForm extends javax.microedition.midlet.MIDlet implements CommandListener { Display display; boolean commandAvailable; String idPassword; CommandThread commandThread; Form inputForm; Form outputForm; TextField userid; TextField password; Form counterForm; StringItem response; Command cmdExit; Command cmdOK; publicvoid startApp() { display = Display.getDisplay(this); inputForm = new Form(null); userid = new TextField("User",null,25,TextField.ANY); inputForm.append(userid); password = new TextField("Password",null,15,TextField.PASSWORD); inputForm.append(password); cmdOK = new Command("OK",Command.SCREEN,1); cmdExit = new Command("Exit",Command.EXIT,1); inputForm.addCommand(cmdOK); inputForm.addCommand(cmdExit); inputForm.setCommandListener(this); outputForm = new Form(null); response = new StringItem(null,null); outputForm.append(response); outputForm.addCommand(cmdExit); outputForm.setCommandListener(this); commandAvailable = false; commandThread = new CommandThread(this); commandThread.start(); display.setCurrent(inputForm); } publicvoid pauseApp() { } publicvoid destroyApp(boolean unconditional) { } publicvoid commandAction(Command cmd, Displayable d) { if (cmd == cmdExit) { destroyApp(false); notifyDestroyed(); } elseif (cmd == cmdOK) synchronized(this) { commandAvailable = true; notify(); } } } class CommandThread extends Thread { MIDlet parent; boolean exit = false; public CommandThread(MIDlet parent) { this.parent = parent; } publicvoid run() { while (true) { synchronized(parent) { while(!commandAvailable) { try { parent.wait(); } catch (InterruptedException e) { } } commandAvailable = false; } performLogin(); } } publicvoid performLogin() { HttpConnection conn = null; InputStream is = null; OutputStream os = null; byte[] receivedData = null; try { String url = "http://172.17.171.133/XYZ_Technologies?user=shaun&password=bogekko"; conn = (HttpConnection)Connector.open(url); conn.setRequestMethod(HttpConnection.POST); conn.setRequestProperty("User-Agent","Profile/MIDP-2.0 Configuration/CLDC-1.0"); conn.setRequestProperty("Content-type","application/x-www-form-urlencoded"); byte[] postData = createPostData(); os = conn.openOutputStream(); os.write(postData); is = conn.openInputStream(); String contentType = conn.getType(); int len = (int) conn.getLength(); if (len > 0) { receivedData = newbyte[len]; int nb = is.read(receivedData); } else { receivedData = newbyte[1024]; int ch; len = 0; while ((ch = is.read()) != -1) { receivedData[len++] = (byte) ch; } } response.setText(new String(receivedData,0,len)); display.setCurrent(outputForm); } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); } finally { try { if (is !=null) { is.close(); } if (os !=null) { os.close(); } if (conn !=null) { conn.close(); } } catch (IOException e) { } } } publicbyte[] createPostData() { StringBuffer sb = new StringBuffer(); sb.append("userid="); sb.append(userid.getString()); sb.append("&password="); sb.append(password.getString()); System.out.println("sb = <" + sb.toString() + ">"); } } |
|
#2
|
||||
|
||||
|
What, no line numbers in the error messages and no markers in the code pointing to line numbers? Can't do much with this, I'm afraid.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > Need help in solving errors..urgent |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|