B4J Question [SOLVED] jServer programmatically serving root "/" page

quique

Member
Licensed User
Longtime User
Hi There!

This most probably is obvious, but these are my first minutes / hours with b4J.

I am trying to delve into my first project, by creating a webserver, based on ServerHelloWorld example from some years ago.

I got a question:

1) It seems that the document for root URL "/" (http://localhost:8888/) is hardwired into a static file index.html I should place in the folder declared by StaticFilesFolder. If I set StaticFilesFolder into /objects/www and place an index.html inside, then it gets served OK as response for the "/" URL.

If I try to use AddHandler in order to have a Server Handler class module take care of the "/", I get the following error: java.lang.IllegalStateException: Multiple servlets map to path /: anywheresoftware.b4j.object.JServlet-282ba1e[mapped:EMBEDDED:null],org.eclipse.jetty.servlet.DefaultServlet-326de728[mapped:EMBEDDED:null]

Is there any way of programmatically handling the root url "/" ?


Regards,

Enrique
 
Last edited:

quique

Member
Licensed User
Longtime User
Sorry, I answered myself ... it started to work when i tried

B4X:
srvr.AddHandler("","index", False)

instead of:

B4X:
srvr.AddHandler("/","index", False)

(Notice the "/" as root is not ok).

Regards,

Enrique
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
other option should be with a filter class and redirect
 
Upvote 0
Top