B4J Question Restrict access to jserver via https

You need to do this with a filter.

Before you start the server

Code: Copy
    'http to https redirect
    webserver.AddFilter("/*", "https_filter", False)

And the filter;

Code: Copy
'Filter class
Sub Class_Globals
   
End Sub

Public Sub Initialize
   
End Sub

'Return True to allow the request to proceed.
Public Sub Filter(req As ServletRequest, resp As ServletResponse) As Boolean
    If req.Secure Then
        Return True
    Else
        resp.SendRedirect(req.FullRequestURI.Replace("http:", "https:"))
        Return False
    End If
End Sub
 
Upvote 0
Back
Top