Skip to main content

Understanding Grizzly part I: Embedding Grizzly HTTP Web Server in 5 lines

Posted by jfarcand on December 8, 2006 at 11:33 AM PST

This blog has moved here

Related Topics >>

Comments

hi how to publish my papers help me please

Which version are you using? startEndpoint block because it start listening on the port you selected. Try using SelectorThread.listen() method or spawn a thread that invoke startEndpoint(). Next time if you can post your question on users@grizzly.dev.java.net....a lot of code/peoples can help! Thanks!

Hi, I am trying to use this example in my implementation of a binding component in JBI, but for some reason the call to selectorThread.startEndpoint() hangs forever. If I implement it as a standalone java application it works as it should, but not within JBI (in glassfish). Any idea what might be the problem?

Hi, have you added the proper location when you started Grizzly. Something like java -jar grizzly.jar 8082 PATH_TO_INDEX.html? Thanks!

Hi, I tried your code to run WebServer by starting SelectorThread but when i tried to get index.html file from the server, it return blank page example http://localhost:8082/index.html , i just want to access some static file, let me know how to do this.I have index.html file in the start directory. I used port 8082 . Thanks for your great work. Pai

Right. By default, the SelectorThread will execute on the same thread as the client. To implement what you want, just do SelectorThread.start() instead of SelectorThread.startEndpoint(). Thanks!

Jean-Francois, I tried to start two SelectorThread endpoints in one class and the first thread never returned to allow the main to start the second. How can I accomplish this? My end goal is to basically create two simple servers on ports 8080 and 9090 and create a pass-through proxy where the input request stream of the first is wired to the second server whose port is being held open indefinitely. Any idea on the simplest way to create this? Jeff