
Build a to-do management web app with login and logout in 25 steps, mastering Spring MVC basics, DispatcherServlet, view resolver, controllers, data binding, and REST services.
Get an overview of course tools and repository organization, install Eclipse, Maven, and Java, and learn through zip-delivered steps to build a Spring MVC todo app with login.
Set up your first Java web application in Eclipse with embedded Maven, create a simple war-packaged Maven project, and run it on tomcat7:run to see my first servlet at localhost:8080.
Learn to configure pom.xml with tomcat maven plugin and compiler plugin, add Java EE Web API, and set up web.xml and login servlet for a functional web app.
Explain what a servlet is and how it handles http requests and responses to build a java web application using the java enterprise edition servlet technology.
Demonstrates the web application request flow: the browser sends a GET http request to localhost:8080, the server processes the input, and returns an http response with HTML.
Create the login servlet by extending HttpServlet and mapping the url /login.do with @WebServlet. Handle get requests in doGet using HttpServletRequest and HttpServletResponse, writing output with a PrintWriter.
Create a login servlet from scratch, annotate with @WebServlet and map /login.do, then implement doGet to write a response, and forward to WEB-INF/views/login.jsp to render the view.
Playful learning means tinkering with URLs, JSPs, and servlets in the spring mvc beginners project. Watch the Tomcat context auto-reload and note 200 vs 404 statuses as you modify files.
Learn how to pass get parameters from the browser to a servlet and forward to a JSP, using request.getParameter, request attributes, and expression language.
Learn how a jsp functions as a servlet, use scriptlets and expression language, and why keep business logic out of jsps by employing el and jstl.
Examine the disadvantages of get parameters by adding a password, showing how passwords in the URL travel across routers and are insecure, with post introduced for next steps.
Create a simple HTML form to submit data via post to a login.do servlet, compare get versus post, and prepare to handle the do post method in the next step.
Implement post handling in the login servlet by converting doGet to doPost, redirecting to welcome.jsp, and displaying the entered name using request attributes and expression language.
Add a password field to the login form using input type password, implement a user validation service, and route valid users to welcome.jsp with an error message for invalid credentials.
Code on Github : https://github.com/in28minutes/SpringMvcStepByStep
Set up a Spring MVC web app by adding spring-webmvc, configure the dispatcher servlet in web.xml as the front controller, and create a Spring context file (todo-servlet.xml) with component scanning.
Configure your first Spring MVC controller and map the /login URL via @Controller and @RequestMapping; let the dispatcher servlet route requests and use @ResponseBody to return Hello World.
Configure a spring mvc view with an internal resource view resolver prefix web-inf/views and suffix .jsp to map login to login.jsp, illustrating the dispatcher servlet flow from the login controller.
Explore the Spring MVC architecture, highlighting the front controller, dispatcher servlet, and how /login routes from web.xml to a login controller, view resolver, and login.jsp in Tomcat.
Practice with Spring MVC by changing URLs, JSPs, and XML configurations to see how the dispatcher servlet loads contexts and throws errors, then create new controllers to explore behavior.
Add the Log4j framework via Maven to a Spring MVC app, configure log4j.properties, and experiment with log levels to observe dispatcher servlet activity.
Demonstrates using ModelMap and @RequestParam in spring mvc to capture login input and display it on the welcome page, routed by the dispatcher servlet with GET and POST handling.
Apply the login service to validate user ID and password in a Spring MVC controller, replacing old servlet code and mapping all requests to /login with model-based error messaging.
Learn how Spring automates dependency management with autowiring and dependency injection, letting LoginController receive a LoginService bean created by @Service and injected via @Autowired, through component-scan.
Create a Spring MVC todo model and a static TodoService with add, delete, and retrieve methods; wire it into a TodoController and display todos on list-todos.jsp using a model map.
Explore the evolution of Java web app architectures from model 1, where JSPs handled all logic, to model 2 MVC with a Friend Controller pattern in Spring MVC.
Delve into Spring modules from the core container and bean life cycle to application context, exploring Spring MVC, Spring JDBC, Spring ORM, Spring JMS, OXM, transactions, and Spring AOP.
Demonstrates the difference between request and session scopes and shows how @SessionAttributes makes model data persist across views in login and list todos flows.
Learn to add a new todo in Spring MVC by creating a todo form, implementing addtodo for GET and POST, and redirecting to list-todos with model.clear to refresh the list.
Render a todo list in a JSP using the JSTL forEach tag, declare the JSTL tag library, and present todos in a table with description, target date, and is completed.
Learn to style a Java web app with Bootstrap via WebJars in a Spring MVC project, applying container, table, table-striped, and btn classes.
Learn to add a delete button for each to-do, wire a get-based delete endpoint with an id, call the to-do service to remove it, and redirect back to the list.
Format add todo page with bootstrap to enhance styling and implement html5 validations, starting with a required description field. Front-end checks exist, but back-end validations with Hibernate Validator are planned.
Create a Todo command bean, bind the form to the bean with Spring form tags, and validate input using JSR 349 with Hibernate Validator.
Implement bean validations in the to-do form using hibernate validator and @Size(min=6) on the description, then validate with @Valid and BindingResult and display errors on the page.
This step adds update functionality for todos by reusing the todo.jsp form with Spring MVC and command object, implementing retrieveTodo and updateTodo, and updating the controller to handle id-based updates.
Add the target date field to the to-do form and use InitBinder to apply a dd/mm/yyyy date format via a custom date editor, ensuring consistent binding and validation across the controller.
Learn to build a reusable navigation bar with JSP fragments, creating header, navigation, and footer in a common folder, and sharing them across pages while highlighting the active menu item.
Prepare for spring security by removing login functionality, making the welcome page the default, and refactoring the logged-in username retrieval for future security integration.
Set up spring security by adding spring-security-web and spring-security-config, define a SecurityConfiguration with in28Minutes as USER and ADMIN, secure /todo urls, provide a /login page, and configure a delegating filter proxy in web.xml.
Implement logout functionality by retrieving the logged-in username from the security context principal and terminating the Spring Security authentication, redirecting users to the homepage.
Explore theory behind exception handling in Spring MVC, focusing on handling with web.xml or controller advice, and when to use custom exceptions to show user-friendly errors with an exception id.
Implement and centralize exception handling in Spring MVC as a crosscutting concern using a controller advice with a global exception handler, log errors, and route to specific error pages.
Learn how to internationalize a spring mvc app by configuring message sources and a session locale resolver, define language-specific properties, and use spring:message to switch content based on locale.
Create a basic Spring REST web service using a RestController to expose /todos, autowiring a TodoService, returning a JSON list of todos with Jackson for conversion.
Learn how to expose a rest service with a path variable to fetch a specific to-do by id, using a path parameter in a Spring rest endpoint.
Explore Spring MVC from basics to advanced features, including DispatcherServlet architecture, ViewResolver, controllers, annotations, forms and data binding, Spring Security, exception handling, internationalization, and basic REST services.
Developing your first Spring MVC Web Application is fun. In this course, you will learn the basics of Spring MVC developing a Basic Todo Management Application with Login and Logout functionalities.
WHAT OUR LEARNERS ARE SAYING:
★★★★★ "Great course to get basic knowledge of Spring MVC. Instructor is great, explanations are clear and simple. I recommend it to everyone interested in basics of java web. Thanks!"
★★★★★ "The author explain everyting nicely. App build from scratch All the spring magic and feature explained."
★★★★★ "Speechless! Finally something of quality that's worth buying. Please release more on Spring like Rest, Hadoop etc. Also don't forget Play framework."
★★★★★ "A very good introduction to Spring MVC. I especially like the way Ranga encouraged the student to play around with the framework and try "to break it." This gives great insight into what annotations and tags do what."
COURSE OVERVIEW:
You will build the website step by step - in more than 25 steps. This course would be a perfect first step as an introduction to Java Web Application Development.
You will be using Spring (Dependency Management), Spring MVC, Spring Security (Authentication and Authorization), BootStrap (Styling Pages), Maven (dependencies management), Eclipse (IDE) and Tomcat Web Server. We will help you set up each one of these.
You will learn about
DispatcherServlet
Basic Todo Management Application with Login/Logout
Model, Controllers, ViewResolver and Filters
Forms - DataBinding, Validation
Annotation based approach - @RequestParam, @PathVariable, @ModelAttribute, @SessionAttributes etc
Bootstrap to style the page
Spring Security
Internationalization
Exception Handling
Basic REST Services
Step Wise Details
Step 11 : Configure application to use Spring MVC
Step 12 : First Spring MVC Controller, @ResponseBody, @Controller
Step 13 : Redirect to Login JSP - LoginController, @ResponseBody and View Resolver
Step 14 : DispatcherServlet and Log4j
Step 15 : Show userid and password on the welcome page - ModelMap and @RequestParam
Step 16 : LoginService and Remove all JEE Servlets based code
Step 17 : Spring Auto-wiring and Dependency Management - @Autowired and @Service
Step 18 : Create TodoController and list-todos view. Make TodoService a @Service and inject it.
Step 19 : Web Application Architecture
Step 20 : More about Spring Framework
Step 21 : Session vs Model vs Request - @SessionAttributes
Step 22 : New Todo and redirect to a Controller
Step 23 : JSTL
Step 24 : Bootstrap - using Webjars
Step 25 : Let's delete a Todo
Step 26 : Use Bootstrap to format and add HTML5 Validations
Step 27 : Introduce JSR 349 Validations using Hibernate Validator - First Command Bean.
Step 28 : Let's update a Todo
Step 29 : Let's add a Target Date for Todo - Use initBinder to Handle Date Fields
Step 30 : Navigation bar and JSP Fragments
Step 31 : Let's prepare for Spring Security
Step 32 : Initial Setup for Spring Security
Step 33 : Refactor and add Logout Functionality using Spring Security
Step 34 : Exception Handling in Spring MVC - @ControllerAdvice, @ExceptionHandler and error-page in web dot xml
Step 35 : Let's add Internationalization - i18n
Step 36 : Basic Spring Rest Services - @RestController and jackson-databind
Step 37 : More Rest Services - @PathVariable
We do NOT interact with a Database in this Beginner’s Course.