I'm trying to send data, string or binary format from an application written with B4J to a servlet written in pure Java.
I have tried in various ways, but I can not read the servlet data. Can anyone help me.
B4j Code
Java Code
the log show the dimension of data to receive to server, but I'm not able to read the data from server
client B4J app
lenght string = 31
Java
len buffer 31
thank in advance for any support.
roberto
I have tried in various ways, but I can not read the servlet data. Can anyone help me.
B4j Code
B4X:
Dim j As HttpJob
j.Initialize("send_data", Me)
Dim sData As String = "send data to server from client"
LogError("lenght string = " & sData.Length)
j.PostString("http://localhost:8080/devagonsit/servlet/ServletSynchro?name=pippo&city=milan", sData)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log("chiamata avvenuta con successo x invio bytes")
j.Release
Else
LogError("Chiamata servelet fallita")
End If
Java Code
B4X:
ServletInputStream is = request.getInputStream();
BufferedReader br = null;
StringBuilder stringBuilder = new StringBuilder();
out.println("len buffer " + request.getContentLength());
if (is != null) {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
char[] charBuffer = new char[128];
int bytesRead = -1;
while ((bytesRead = bufferedReader.read(charBuffer)) > 0) {
stringBuilder.append(charBuffer, 0, bytesRead);
}
out.println("lettura dati dal client " + stringBuilder.toString());
}
out.println("fine della lettura dei dati....");
the log show the dimension of data to receive to server, but I'm not able to read the data from server
client B4J app
lenght string = 31
Java
len buffer 31
thank in advance for any support.
roberto