
Quick Contact
Java Tutorial
- What is Java?
- History of Java
- Hello Java Program
- Features of Java
- Basic Syntax
- Java Setup
- Data Types in Java
- Java Variables
- Operators in Java
- JVM
- Java If-else Statement
- Switch Case Statement
- Java Loops
- Do-While Loop
- Java While Loop
- Continue Statement
- Break Statement in Java
- Constructors in Java
- Oops Concept in Java
- Features of OOPs
- Inheritance
- Exeception handeling
- Aggregation (HAS-A relationship) in Java
- Method Overriding in Java
- Method Overloading
- Java Static Keyword
- Java This Keyword
- Java Final Keyword
- Polymorphism
- Static Binding and Dynamic Binding
- Abstract class in Java
- Access Modifiers in Java
- Difference between abstract class and interface
- Interface in Java
- Garbage Collection in Java
- Java Package
- Encapsulation
- Serialization and Deserialization in Java
- Java Inner Classes
- Java Applets
- Multithreading in Java
- Thread Priorities in Java
- Thread Creation
- Inter Thread Communication
- Wrapper Classes in Java
- Java Input Output
- Java AWT Introduction
- Java Layout Manager
- Java Layout Policy
- Java AWT Events
- Collection Framework
- Collection Framework List Interface
- Swing in Java
- Swing Utility Classes
- Swing Layout Managers
- Java JDBC
- Hibernate Framework Overview – Architecture and Basics
Springboot
- Spring Environment Setup
- Spring Boot CRUD REST API Project using IntelliJ IDEA | Postman | MySQL
- Dockerizing Spring Boot Application | Spring Boot Docker Tutorial
- spring-boot-restapidocumentation with swagger
- Spring Boot HttpClient Overview
- Apache HttpClient POST HTTP Request Example
- Apache HttpClient PUT HTTP Request Example
- Apache HttpClient DELETE HTTP Request Example
- Apache HttpClient HTML Form POST Request Example
- Spring Boot JSP Exampl
- Deploying Spring Boot WAR file with JSP to Tomcat
- Spring Boot Annotations
- Spring Core Annotations
- Spring MVC Annotations with Examples
- Spring Scheduling Annotations
- Spring - Java-based Container Configuration
- Spring Java Based Configuration Example
Hibernate
- Hibernate 5 hello world
- Hibernate- One to One Unidirectional Mapping Annotation Example
- Hibernate - Batch Processing
- Hibernate - Interceptors
- Hibernate 5 - Create, Read, Update and Delete (CRUD) Operations Example
- Hibernate Transaction Management
- Hibernate One to Many Unidirectional Mapping Example
- Hibernate One to Many Bidirectional Mapping Example
- Hibernate Many to Many Annotation Mapping Example
- Hibernate Primary KeyJoin Column
- Hibernate First Level Cache with Example
- Hibernate XML Configuration Example with Maven + Eclipse + MySQL Database
- Hibernate Java Configuration Example
- JPA 2 with Hibernate 5 Bootstrapping Example
- JPA and Hibernate Cascade Types
- Hibernate/JPA - Primary Key Generation
- Hibernate 5 - Enum Type Mapping Example
- Hibernate Component Mapping
- Hibernate Object States – Transient,Persistent and Detached
- Hibernate 5 - Save an Entity Example
- Hibernate 5 - Persist an Entity Example
- Hibernate 5 - saveOrUpdate() Method Example
- Hibernate 5 - get(), load() and byId() Method Examples
- Hibernate 5 - merge() Example
- Hibernate 5 - Delete or Remove an Entity Example
- Hibernate 5 - load() Method Example
- Hibernate Session Interface Methods
- Hibernate Session.clear() Method Example
- Introduction Of Java strutes to Architecture
- Struts 2 - Architecture
- Struts 2 - Configuration Files
- Struts 2 - Actions
- Struts 2 - Interceptors
- Struts 2 - Results & Result Types
- Struts 2 - Value Stack/OGNL
- Struts 2 - File Uploading
- Struts 2 - Database Access
- Struts 2 - Validations Framework
JAVA FX
- JavaFX Tutorial
- Introduction to JavaFX Pane
- JavaFX Popup
- JavaFX group
- JavaFX Controller
- JavaFX Gradient Color
- JavaFXAnchorPane
- JavaFXTabPane
- JavaFX Scene
- JavaFX Stage
- JavaFXWebView
- JavaFX Timeline
- JavaFX Timer
- JavaFX Image
- JavaFX Background
- JavaFX dialog
- JavaFX Font
- JavaFXTextArea
- JavaFXObservableList
- JavaFX GUI
- JavaFX FXML
- JavaFXEventHandler
- JavaFXGradle
- JavafxScrollpane
- JavaFXAPI
Spring Boot JSP Example
Spring Boot aims to make it easy to create Spring-powered, production-grade applications and services with minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need.
JSP is a Java-based server-side template engine to create dynamic web pages.
Tools and technologies used
- Spring boot 2+
- Spring framework 5+
- IDE – Eclipse STS
- Maven 3+
- Embedded tomcat server 8.5+
- JSP/JSTL
Development Steps
- Create Spring Boot project.
- Add maven dependencies.
- Create Spring MVC Controller.
- Spring Boot JSP ViewResolver Configuration.
- Create JSP page.
- Run app and demo.
-
Create a Spring Boot Application
There are many ways to create a Spring Boot application. You can refer below articles to create a Spring Boot application.
>> Create Spring Boot Project With Spring Initializer
>> Create Spring Boot Project in Spring Tool Suite [STS]
-
Add maven dependencies
< ?xml version="1.0" encoding="UTF-8"?> < project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> < modelVersion>4.0.0< /modelVersion> < parent> < groupId>org.springframework.boot< /groupId> < artifactId>spring-boot-starter-parent< /artifactId> < version>2.2.6.RELEASE< /version> < relativePath /> < !-- lookup parent from repository --> < /parent> < groupId>net.ducatindia< /groupId> < artifactId>springboot-jsp-hello-world-example< /artifactId> < version>0.0.1-SNAPSHOT< /version> < name>springboot-jsp-hello-world-example< /name> < description>Demo project for Spring Boot and JSP< /description> < packaging>war< /packaging> < properties> < java.version>1.8< /java.version> < /properties> < dependencies> < dependency> < groupId>org.springframework.boot< /groupId> < artifactId>spring-boot-starter-web< /artifactId> < /dependency> < dependency> < groupId>org.springframework.boot< /groupId> < artifactId>spring-boot-starter-thymeleaf< /artifactId> < /dependency> < dependency> < groupId>org.apache.tomcat.embed< /groupId> < artifactId>tomcat-embed-jasper< /artifactId> < /dependency> < !-- JSTL for JSP --> < dependency> < groupId>javax.servlet< /groupId> < artifactId>jstl< /artifactId> < /dependency> < dependency> < groupId>org.springframework.boot< /groupId> < artifactId>spring-boot-starter-test< /artifactId> < scope>test< /scope> < exclusions> < exclusion> < groupId>org.junit.vintage< /groupId> < artifactId>junit-vintage-engine< /artifactId> < /exclusion> < /exclusions> < /dependency> < /dependencies> < build> < finalName>springboot-webapp< /finalName> < plugins> < plugin> < groupId>org.springframework.boot< /groupId> < artifactId>spring-boot-maven-plugin< /artifactId> < /plugin> < /plugins> < /build> < /project>
In order to work with JSP/JSTL, we need to add below two dependencies:
< dependency> < groupId>org.apache.tomcat.embed< /groupId> < artifactId>tomcat-embed-jasper< /artifactId> < /dependency> < !-- JSTL for JSP --> < dependency> < groupId>javax.servlet< /groupId> < artifactId>jstl< /artifactId> < /dependency>
-
Create Spring MVC Controller
Let’s create a simple spring MVC controller with method handler:
packagenet.ducatindia.springboot.controller; importorg.springframework.stereotype.Controller; importorg.springframework.ui.Model; importorg.springframework.web.bind.annotation.GetMapping; importorg.springframework.web.bind.annotation.RequestParam; @Controller publicclassHelloController { @GetMapping({ "/", "/hello" }) publicStringhello(@RequestParam(value="name", defaultValue="World", required=true) Stringname, Modelmodel) { model.addAttribute("name", name); return"hello"; } }
-
JSP ViewResolver Configuration in application.properties file
Let’s add below properties in application.properties file to configure view resolver for JSP:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
-
Create JSP page
Let’s create a simple JSP page under webapp/WEB-INF/jsp folder structure. If webapp folder not exists then create webapp/WEB-INF/jsp folder structure and then create JSP pages under it.
<%@ pagelanguage="java"contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> < !DOCTYPE html> < html> < head> < metacharset="ISO-8859-1"> < title>Insert title here< /title> < /head> < body> < h2align="center"> Hello ${name}!< /h2> < /body> < /html>
-
Run app and demo
Let’s run this spring boot application from IDE -> Right click -> Run As -> Java Application:
packagenet.ducatindia.springboot; importorg.springframework.boot.SpringApplication; importorg.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication publicclassSpringbootJspHelloWorldExampleApplication { publicstaticvoidmain(String[] args) { SpringApplication.run(SpringbootJspHelloWorldExampleApplication.class, args); } }
Apply now for Advanced Java Training Course