java - login form using jsp and servlets without DBMS -


i'm trying create login form blog system. have completed login form using jsp, need use servlet process login details. tutorial following uses dbms query form details , authenticate user. how can go without using database?

this tutorial following, http://www.ganeshtechblog.in/2013/09/creating-simple-login-form-using-eclipse.html

you use local database ? tip: xampp

or can hardcode user id , pw in servlet.

you can make them following: @ top of servlet add:

 private static final string id="idvalue",pw="pwvalue"; 

then

 string userid = request.getparameter("userid");  string password = request.getparameter("pwd"); 

you 2 values view... have check if correct witht hard coded ones...

if(userid.equals(id) && password.equals(pw)){             // fetch session request, create new session if session             // not present in request             httpsession session = request.getsession(true);              session.setattribute("firstname", rs.getstring("firstname"));             session.setattribute("lastname", rs.getstring("lastname"));             // redirect success page             response.sendredirect("loginsuccess.jsp");  }else{ // redirect error page             response.sendredirect("loginfailure.jsp"); } 

i wouldn't use real application though...

ps. 1 simple solution, there many better way's...


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -