Hi, All
What's wrong with the code ?
It's plain HTML generated page, without JS (that is unknown for me), just single handler:
How to get form parameters ? Why method is wrongly got ?
What's wrong with the code ?
It's plain HTML generated page, without JS (that is unknown for me), just single handler:
B4X:
srvr.AddHandler("/grabber_settings", "grabber_settings", False)
Single handler app::
Sub Handle(req As ServletRequest, resp As ServletResponse)
Try
Log(CRLF & "------------" & CRLF & "Method: " & req.Method)
Log("ContentType: " & req.ContentType)
Log(req.GetSession.GetAttributesNames)
Dim Params As Map = req.ParameterMap
Log(Params)
Dim new_url As String = req.GetParameter("RTSP_URL")
If new_url <> "" Then
Main.Grabbing = False
Main.RTSP_URL = new_url
End If
If Params.ContainsKey("btnStart") Then
Main.Grabbing = True
End If
If Params.ContainsKey("btnStop") Then
Main.Grabbing = False
End If
resp.Write("<html><body><form method='POST' action='grabber_settings'>")
Dim rtsp_form As String = $"Source IP-camera RTSP address: <input type="text" id="RTSP_URL" size = "50" value = "$ & Main.RTSP_URL & "></input>"
rtsp_form = rtsp_form & $"<button type="Submit">Save URL</button><br>"$
resp.Write(rtsp_form)
resp.Write("<br>").Write("Grabbing service: " & (IIf(Main.Grabbing, $"<button type="Submit" id="btnStop">STOP</button>"$, _
$"<button type="Submit" id="btnStart">START !</button>"$)))
resp.Write("</form></body></html>")
Catch
resp.SendError(500, "Server internal error")
End Try
End Sub
Waiting for debugger to connect...
Program started.
2022-08-27 14:03:17.703:INFO ejs.Server:main: jetty-11.0.9; built: 2022-03-30T17:44:47.085Z; git: 243a48a658a183130a8c8de353178d154ca04f04; jvm 11.0.1+13
2022-08-27 14:03:17.859:INFO ejss.DefaultSessionIdManager:main: Session workerName=node0
2022-08-27 14:03:17.881:INFO ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@169e6180{/,file:///P:/GoogleDrive/Shell/Shell-VTK/Stan-C4/Soft/B4J/sc4grab/Objects/www/,AVAILABLE}
2022-08-27 14:03:17.916:INFO ejs.RequestLogWriter:main: Opened P:\GoogleDrive\Shell\Shell-VTK\Stan-C4\Soft\B4J\sc4grab\Objects\logs\b4j-2022_08_27.request.log
2022-08-27 14:03:18.151:INFO ejs.AbstractConnector:main: Started ServerConnector@145eaa29{HTTP/1.1, (http/1.1)}{0.0.0.0:51042}
Emulated network latency: 100ms
2022-08-27 14:03:18.175:INFO ejs.Server:main: Started Server@61df66b6{STARTING}[11.0.9,sto=0] @1359ms
Server is started
------------
Method: GET
ContentType:
(ArrayList) []
(MyMap) {}
How to get form parameters ? Why method is wrongly got ?
Last edited: