B4J Question [SOLVED] Setting a Content header using jserver

Peter Lewis

Active Member
Licensed User
Longtime User
Hi All

I have been developing an Webapp using jserver and since I have got to a stage now where I want to validate my html using the online W3 validator, I need this problem solved.

I looked at other info on the forum but only found info to do with okhttp.

This is the error I get when validating one of my webpages. Any Advise would be helpful. Thank you
1634287785967.png




Here is the code used to initializing the server.
B4X:
    utils.pool.As(JavaObject).RunMethod("setMaximumPoolSize", Array(5))
    templates.Initialize
    templates.DefaultEncoding = "UTF-8"
    templates.DirectoryForTemplateLoading = File.DirApp & "/templates"
    server.Initialize("srvr")
    server.StaticFilesFolder = File.DirApp & "/www"

    server.Port = connectionMap.Get("ServerPort")

    'HANDLERS - app
    urls = server.CreateThreadSafeMap
   
    urls.Put("clsAuth","/auth")
   
   
    server.AddFilter("/portal/*","fltLogin",False)
   
    'HANDLERS - web outside secure area
   
    urls.Put("clsLanding","")
    urls.Put("clsdjinfo","/info")
    urls.Put("clsdjgrid","/djgrid")
    urls.Put("clscollectdjinfo","/collectdjinfo")
    urls.Put("clsSearchGrid","/searchgrid")

   
    'registration and logins
    urls.Put("clsCoupleRegister","/coupleregister")
    urls.Put("clsLoginRegister","/register")
    urls.Put("clsConfirmation","/confirmation")
    urls.Put("clsLogin","/login")
    urls.Put("clsLogout","/logout")
    'remote url profile
    urls.Put("clsRemoteShare","/remoteshare/*")
    'htmx
    urls.Put("clsGetRegions","/getregions")
    '===========================================================
    'HANDLERS - web inside secure area
   
    'Service Provider area
    urls.Put("clsVendorDashboard","/portal/vendordashboard")
    urls.Put("clsVendorListings","/portal/vendorlistings/*")
    urls.Put("clsVendorListingsAdd","/portal/vendorlistingsadd/*")
    urls.Put("clsVendorProfileEdit","/portal/vendorprofileedit")
    urls.Put("clsVendorPricing","/portal/vendorpricing")
    urls.Put("clsVendorReviews","/portal/vendorreviews")
    urls.Put("clsVendorQuotes","/portal/vendorquotes")
    urls.Put("clsWizardAddListing","/portal/addlistingwizard")
    urls.Put("clsItemDelete","/portal/itemdelete")
    urls.Put("clsUploadGallery","/portal/uploadgallery")
    urls.Put("clsEditTables","/portal/edittables")
    urls.Put("clsAddHeader","/portal/addheader")
    urls.Put("clsVendorListingsEdit","/portal/vendorlistingsedit")
    urls.Put("clsViewVisitors","/portal/viewvisitors")
    'Couple are
   
    urls.Put("clsCoupleSeatingPlan","/portal/coupleseatingplan")
    urls.Put("clsCoupleAddGuest","/portal/coupleaddguest")
    urls.Put("clsCoupleGuestList","/portal/coupleguestlist")
    urls.Put("clsCoupleBudget","/portal/couplebudget")
    urls.Put("clsCoupleTodolist","/portal/coupletodolist")
    urls.Put("clsCoupleWishlist","/portal/couplewishlist")
    urls.Put("clsCoupleDashboard","/portal/coupledashboard")
   
    'htmx
    urls.Put("clsGetPictures","/portal/getpictures")
    urls.Put("clsGetHighlights","/portal/gethighlights")
    urls.Put("clsGetTable1","/portal/gettable1")
    urls.Put("clsGetTable2","/portal/gettable2")
    For Each url In urls.Keys
    server.AddHandler(urls.Get(url),url,False)
    Next
    server.AddBackgroundWorker("clsipGeoLocation")
    Log("Port : "&server.Port)
    server.SetStaticFilesOptions(CreateMap("dirAllowed": False))
    server.Start
    Log("ready")
    StartMessageLoop

I have tried
B4X:
resp.ContentType="text/html"
 
Last edited:
Top