B4J Question jServer setting page content based on outside server's response

mc73

Well-Known Member
Licensed User
Longtime User
Here's the case: I have an activation page served by jServer. Upon data submission, I post these data to an external server's php, in order to validate the installation, which then sends back a confirmation.
The problem is, I cannot get the jServer's servlet response really get these data. It seems to me like there's a time limitation or something.
For now, I reopen a browser's window in order to set the final confirmation, but it would be better to simply feed the servlet with data.

Here's how the code was organized:

B4X:
Sub Handle(req As ServletRequest, resp As ServletResponse)
.......
Case "validate"
       intraSetLicence2(req.ParameterMap,resp)
........
end select
end sub

Sub intraSetLicence2(myMap As Map,myResp2 As ServletResponse)
 myResp=myResp2:' a private holding the servlet
Dim jb As HttpJob
   Dim myQuery As String =myDataHere
   jb.Initialize("validate",Me)
   jb.PostString(myExternalPage,myQuery)
end sub

Sub jobDone (job As HttpJob)
   Log("JobName = " & job.JobName & ", Success = " & job.Success)
  Dim s As String
   If job.Success = True Then
  s=job.GetString
    
     job.Release
     
   Else
     s="error"
    
   End If
   createFinalLicence3(s)
End Sub


Sub createFinalLicence3(myString As String)
  
   myResp.ContentType = "text/HTML;charset=UTF-8"
   myResp.write(myString)
.....

End Sub
In reality the above code, is using AJAX to insert data in a div. Before this attempt, I had setting data with no AJAX.
I have to mention that everything works ok, online validation, response, it's just that I cannot set the response (it seems to load before the arrival of data). Is it perhaps a time limitation?
 

mc73

Well-Known Member
Licensed User
Longtime User
Ah, great! I had tried startMessageLoop, but I ended it at the final sub, while putting at the end of jobDone did the trick. Thank you very much.
 
Upvote 0
Top