B4J Tutorial [Server] Building web servers with B4J

Discussion in 'B4J Tutorials' started by Erel, Jan 27, 2014.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    You are referring to the StaticFilesFolder.

    What do you mean with the requested hostname? Can you give an example?
     
  2. wl

    wl Well-Known Member Licensed User

    Hi Erel,

    What I meant was:

    You run the webserver on a machine that is hosting websites for www.domain1.com and www.domain2.com (both resolving to the same IP of course = IP on which the webserver is running). The staticfilesfolder for requests to www.domain2.com should be a folder \domain1 and for requests to www.domain2.com should be folder \domain2.

    Thx
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    I see. The static files folder cannot be configured for that. Consider mapping each host to a different port and then run several servers, one for each host.
     
    Last edited: Feb 13, 2014
  4. wl

    wl Well-Known Member Licensed User

    thanks Erel, but that's a bummer. Only possibility would be to put an nginx (or similar) in front of it then...
     
  5. Roberto P.

    Roberto P. Well-Known Member Licensed User

    would be very helpful for a complete sample database connection for data exchange with dektop application or mobile ...
    thanks in advance
     
  6. Erel

    Erel Administrator Staff Member Licensed User

  7. wl

    wl Well-Known Member Licensed User

    Hi,

    As the cookies have not been implemented yet: wouldn't it just be possible to set a cookie by writing/reading the correct HTTP header (Set-cookie:) ?

    Tx
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    Yes. You can manually set cookies with Set-cookie and also read the cookies from the Cookies header.
     
  9. Erel

    Erel Administrator Staff Member Licensed User

  10. rwblinn

    rwblinn Well-Known Member Licensed User

    Great work - based upon B4J v1.8, I have build a simple ToDoServer. See readme.txt and the code for how it works.
    So far this is based upon accessing from the client via a webbrowser.

    [​IMG]

    Download the code here:http://www.rwblinn.de/b4j/b4jhowto/examples/b4jhowtowebserver.zip

    Next is to develop a B4A dedicated client to access this B4J webserver with add, update and delete functionality - or a volunteer can do ;).
     
  11. little3399

    little3399 Active Member Licensed User

    Hi,Erel

    Does the jar file can be put it on the webserver ? such as tomcat ? Tks!
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    The jar file is the web server. You just need to run it like you run any jar.
     
  13. barx

    barx Well-Known Member Licensed User

    What exactly is required to run these server apps. i.e. can they be run on Internet based servers? If, so, what is required. Can they run on shared plans (i'm doubting it), vps, etc??

    It looks very, very interesting and I have literally just started trying to learn Symfony2. This B4J solutions looks similar in structure (MVC).

    Thanks
     
  14. Erel

    Erel Administrator Staff Member Licensed User

  15. chrjak

    chrjak Active Member Licensed User

    This is my error when i tick the JServer Library:

    Parsing code. 0.01
    Compiling code. 0.02
    Compiling generated Java code. Error
    Cannot find: C:\Program Files (x86)\Anywhere Software\B4J\libraries\jetty_b4j.jar

    :(

    Edit: News: I downloaded the latest Version of b4j and installed it. Now there is no error.
    But the Designer in the Menu Bar is gray and i have a question:

    How do you get these numbers? (192.168....:8888)
    Edit 2: In the Log is 0.0.0.0:8888 - but i can't connect to it
     
    Last edited: Apr 23, 2014
  16. Erel

    Erel Administrator Staff Member Licensed User

    Yes, because it is a non-UI application.

    Start with the local browser. You can then connect with 127.0.0.1:8888

    For further help please start a new thread. I also recommend you to check the WebApp hello world example.
     
  17. Erel

    Erel Administrator Staff Member Licensed User

  18. chrjak

    chrjak Active Member Licensed User

    Thank you. i will return the the old threat again. see you there
     
  19. cstangor

    cstangor Member Licensed User

    I don't understand which files need to be uploaded to my server for this to function.

    I have the files from the www (staticfiles) folder but that doesn't seem to be enough.

    Thanks in advance
     
  20. Erel

    Erel Administrator Staff Member Licensed User

    Assuming that #MergeLibraries attribute is not set to False then you need to copy the jar file and the www folder.

    Make sure to start the server from the correct folder (the jar folder).
     
Thread Status:
Not open for further replies.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice