Q quique Member Licensed User Longtime User Aug 21, 2018 #1 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: Aug 21, 2018
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
Q quique Member Licensed User Longtime User Aug 21, 2018 #2 Sorry, I answered myself ... it started to work when i tried Code: Copy srvr.AddHandler("","index", False) instead of: Code: Copy srvr.AddHandler("/","index", False) (Notice the "/" as root is not ok). Regards, Enrique Upvote 0
Sorry, I answered myself ... it started to work when i tried Code: Copy srvr.AddHandler("","index", False) instead of: Code: Copy srvr.AddHandler("/","index", False) (Notice the "/" as root is not ok). Regards, Enrique
MarkusR Well-Known Member Licensed User Longtime User Aug 24, 2018 #3 other option should be with a filter class and redirect Upvote 0