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
Post a Comment