java - Simple web server with authentication -


i want implement simple web server (like apache), static content. server must offer authentication username , password or ip address.

source code or usefull tutorial helpful.

thanks answers.

if want simple can try jdk 1.6 com.sun.net.httpserver.httpserver, has basic authentication mechanizm:

    httpserver server = httpserver.create(new inetsocketaddress(8888), 0);     httpcontext cc  = server.createcontext("/test", new myhandler());     cc.setauthenticator(new basicauthenticator("test") {         @override         public boolean checkcredentials(string user, string pwd) {             return user.equals("test") && pwd.equals("test");         }     });     server.setexecutor(null); // creates default executor     server.start(); 

if want simple apache try jetty http://www.eclipse.org/jetty/ real web server easy use , can embedded in java standalone app.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -