ok cheers. i will try and get the certificate from our server guy but its proving to be a pain has his not giving it to me!
anyways i tried using a normal http connection and i managed to connect to the server but when i try to right something back to the server i get ajava.lang.illegalStateException stating a "Write attemped after request finished"
im using J2ME with netbeans by the way
here is a revised version of my code. hope someone can help thanks..
Code:
public void open()
{
try
{
server = (HttpConnection) Connector.open(url2);
server.setRequestMethod(HttpConnection.POST);
server.setRequestProperty("If-Modified-Since",
"29 Oct 1999 19:43:31 GMT");
server.setRequestProperty("User-Agent",
"Profile/MIDP-2.0 Configuration/CLDC-1.0");
server.setRequestProperty("Content-Language", "en-US");
is = server.openInputStream();
os = server.openOutputStream();
details();
/*
Alert alert = new Alert ("Error");
alert.setString("ok" + " " + data[0]);
alert.setTimeout (3000);
Display.getDisplay(root).setCurrent(alert);
//something = getResponse();
int gfdgf;
**/
}
catch(Exception e)
{
e.printStackTrace();
String error = e.toString();
Alert alert = new Alert ("Error");
alert.setString("Error, " + e);
alert.setTimeout (5000);
Display.getDisplay(root).setCurrent(alert);
}
}
details method that retreives data and stores into a array
Code:
public void details()
{
try
{
String username = details[0] + "\n" + "\0";
String pass = details[1] + "\n" + "\0";
os.write(username.getBytes());
os.flush();
os.write(pass.getBytes());
os.flush();
for(int i = 0; i < 20; i++)
{
data[i] = getResponse();
}
}
catch(Exception e)
{
e.printStackTrace();
String error = e.toString();
Alert alert = new Alert ("Error");
alert.setString("Error2, " + e);
alert.setTimeout (5000);
Display.getDisplay(root).setCurrent(alert);
}
}
and finaly the method that reads a line of data from the web server
Code:
public String getResponse()
{
StringBuffer b = new StringBuffer();
String read = "";
int ch = 0;
try
{
while(( (ch = is.read()) != '\n') )
{
b.append((char) ch);
}
read = b.toString();
b.setLength(0);
}
catch(IOException e)
{
e.printStackTrace();
read = "error";
}
return read;
}