Develop Java MVC web apps using MyBatis, Servlets and JSP
- Description
- Curriculum
- FAQ
- Reviews
Servlets and JSP
A Java servlet is a Java software component that extends the capabilities of a server. Although servlets can respond to many types of requests, they most commonly implement web containers for hosting web applications on web servers and thus qualify as a server-side servlet web API. Such web servlets are the Java counterpart to other dynamic web content technologies such as PHP and ASP.NET.
A Java servlet processes or stores a Java class in Java EE that conforms to the Java Servlet API, a standard for implementing Java classes that respond to requests. Servlets could in principle communicate over any client–server protocol, but they are most often used with HTTP. Thus “servlet” is often used as shorthand for “HTTP servlet”. Thus, a software developer may use a servlet to add dynamic content to a web server using the Java platform. The generated content is commonly HTML, but may be other data such as XML and more commonly, JSON. Servlets can maintain state in session variables across many server transactions by using HTTP cookies, or URL mapping.
To deploy and run a servlet, a web container must be used. A web container (also known as a servlet container) is essentially the component of a web server that interacts with the servlets. The web container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet and ensuring that the URL requester has the correct access rights.
The Servlet API, contained in the Java package hierarchy javax.servlet, defines the expected interactions of the web container and a servlet.
Servlets can be generated automatically from JavaServer Pages (JSP) by the JavaServer Pages compiler. The difference between servlets and JSP is that servlets typically embed HTML inside Java code, while JSPs embed Java code in HTML. While the direct usage of servlets to generate HTML has become rare, the higher level MVC web framework in Java EE (JSF) still explicitly uses the servlet technology for the low level request/response handling via the FacesServlet. A somewhat older usage is to use servlets in conjunction with JSPs in a pattern called “Model 2”, which is a flavor of the model–view–controller.
MyBatis is a Java persistence framework that couples objects with stored procedures or SQL statements using an XML descriptor or annotations.
Apache MyBatis
MyBatis is free software that is distributed under the Apache License 2.0.
MyBatis is a fork of iBATIS 3.0 and is maintained by a team that includes the original creators of iBATIS.
Unlike ORM frameworks, MyBatis does not map Java objects to database tables but Java methods to SQL statements.
MyBatis lets you use all your database functionality like stored procedures, views, queries of any complexity and vendor proprietary features. It is often a good choice for legacy or de-normalized databases or to obtain full control of SQL execution.
It simplifies coding compared to JDBC. SQL statements are executed with a single line.
MyBatis provides a mapping engine that maps SQL results to object trees in a declarative way.
-
3Overview of MybatisVideo lesson
-
4Eclipse project with required dependenciesVideo lesson
-
5Starting the H2 database in server modeVideo lesson
-
6Entity classes using LombokVideo lesson
-
7Configuring Mybatis to work with our databaseVideo lesson
-
8CustomerDao mapper interfaceVideo lesson
-
9DaoFactory for creating a CustomerDao instanceVideo lesson
-
10Add new customerVideo lesson
-
11Retrieve a customer by idVideo lesson
-
12Update customer dataVideo lesson
-
13Delete a customer recordVideo lesson
-
14Get all customersVideo lesson
-
15Get customers by cityVideo lesson
-
16Overview of web applications in JavaVideo lesson
-
17WAR structureVideo lesson
-
18Setting up Apache Tomcat in EclipseVideo lesson
-
19Create a Maven web projectVideo lesson
-
20Servlet, GenericServlet and HttpServletVideo lesson
-
21Our first servlet classVideo lesson
-
22Handling request parametersVideo lesson
-
23Client side redirectionVideo lesson
-
24Server side include and forwardVideo lesson
-
25The request scopeVideo lesson
-
26The session scopeVideo lesson
-
27The application scopeVideo lesson
-
28Introducing JavaServer Pages (JSP)Video lesson
-
29Our first JSPVideo lesson
-
30JSP ElementsVideo lesson
-
31JSP scripting elements demoVideo lesson
-
32Creating a JSP custom actionVideo lesson
-
33Advanced custom action demoVideo lesson
-
34JSP Expression LanguageVideo lesson
-
35Overview of JSP Standard Tag LibraryVideo lesson
-
36A simple MVC demoVideo lesson
-
37CookiesVideo lesson
-
38FiltersVideo lesson
-
43Overview of registration processVideo lesson
-
44DAO functions - createUser and getUserByEmailVideo lesson
-
45Service function - registerUserVideo lesson
-
46Controller servlet - RegisterServletVideo lesson
-
47View - register.jspVideo lesson
-
48Encrypt password using BCryptVideo lesson
-
49Dashboard controller and viewVideo lesson
External Links May Contain Affiliate Links read more