Validating username and password from database using servlet

If you’ve built a Java web application, you know the involved in building out proper authentication and user management.

Even if you use a great framework like Apache Shiro or Spring Security, there’s still a lot of boring UI work and high risk backend work.

In this first example, client sends user name and password to JSP on the Server. Other scripting elements are Expression and Declaration.

Server receives, validates and sends back the validation result to client as response. Following is the Servlet version for the above JSP file. See the length of coding between a Servlet and JSP doing the same job.

Just drop our Servlet plugin into your Java web application and boom – instant user management with little to no coding required.

This post is a quick tutorial, including Java and JSP code templates, to show you just how quickly you can build a Java web app with a complete set authentication and user management features and user interfaces with Stormpath.

We will focus on our Stormpath-Servlet plugin that has a of user automation.

You just drop a plugin into your web application and boom – instant user management with little to no coding required.

buildscript apply plugin: 'java' apply plugin: 'war' apply plugin: 'com.bmuschko.tomcat' source Compatibility = 1.6 version = '0.1.0' Name = 'stormpath-webapp-tutorial' repositories dependencies tomcat Run.context Path = '/' tomcat Run War.context Path = '/' task wrapper(type: Wrapper) We’ll likely want our web app’s pages to have the same look and feel. And because JSP 2.0 supports page templates automatically via JSP Tags, there is no need to pull in additional template libraries. Register Can you believe that after adding a single home page, you’d have a functional web application with full user management capability? That’s out of scope for this article, but you can read about customizing views later if you wanted. Let’s create the view file that will be rendered by the controller: Welcome to your user dashboard!

Stormpath hooks into typical Java web applications and gives developers all the authentication, authorization, and user security out-of-the-box so you can get on with what you really care about – your application.

In fact, you get full user interfaces without writing a single line of code. By the time you’re done with this tutorial (less than 15 minutes from now), you’ll have a fully-working Java web application.

You’ll build a simple Java web application using the standard Servlet 3 and JSP APIs.

When you’re done, you’ll be able to: – just some configuration! You can start from scratch and complete each step or you can skip the basic setup steps, if you’re already set up with a Stormpath API Key and built your project with Maven/Gradle.

Leave a Reply