B4J Question Scratch extension and B4J

Aristide

Member
Hello,

I am a beginner in B4J. I try to build a HELPER between the Scratch language and a communication layer. The communication between Scratch and the helper needs to embed an Http server.

The queries issued by Scratch are in the form: //IP: port/xxxx/yyy/...

With xxx, yyyy are reserved words that correspond to orders, status requests, ... You can find details here.

I use Jserver library which interprets the "/" as a separator to access the site's repositories and responds with 404.

How to avoid the "/" being interpreted in this sense.

Thank you for your reply.


PS: My English is google translation, please excuse me
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I use Jserver library which interprets the "/" as a separator to access the site's repositories and responds with 404.
That's incorrect.

I assume that xxx is dynamic. In that case you need to add a handler that will catch all requests:
B4X:
srvr.AddHandler("/*", "YourHandler", False)

Print the request URI in the handler:
B4X:
Sub Class_Globals
End Sub

Public Sub Initialize

End Sub

Sub Handle(req As ServletRequest, resp As ServletResponse)
   resp.Write("URI: " & req.RequestURI)
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…