Eclipse J2EE IDE (I am using Eclipse Mars version)
JDK installed (I am using JDK 1.8 version)
Tomcat Server (I am using Tomcat 7.1 version)
1. Create a New Dynamic Web Project
- In Eclipse under Project Explorer Right Click -> New -> Dynamic Web Project.
- Enter Project name: HelloWorld
- Target Runtime: Apache Tomcat vX.X
- Click : Next -> Next
On Web Module Page Check "Generate web.xml deployment descriptor" -> Finish.
2. Creating JSP page :- Right Click on Project Folder HelloWorld -> New -> JSP File.
- Change File Name : index.jsp
- Click Finish
- Add the below lines in bold to your index.jsp page
index.jsp<%@page import="java.sql.Date"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Hello World Program</title>
</head>
<body>
<%= "<h1>JSP : Hello World!!</h1> <br/> Today's DateTime : " %>
<%= new java.util.Date() %>
</body>
</html>
3. Creating Tomcat Server:
- Menu : Window -> Show View -> Servers
- Right Click in Servers tab: New -> Server
- Select the Tomcat Version that you have installed on your system.
- Click on link Add and link to the Tomcat installed location.
4. Running JSP HelloWolrd Project :Right Click on HelloWolrd Project -> Run As -> Run on Server
Run on Server: Click Next -> Finish.
Output :More Posts related to Java,
- Get the current timestamp in Java
- Java Stream with Multiple Filters Example
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to Calculate the SHA Hash Value of a File in Java
- Java JDBC Connection with Database using SSL (https) URL
- How to Add/Subtract Days to the Current Date in Java
- Create Nested Directories using Java Code
- Spring Boot: JDBCTemplate BatchUpdate Update Query Example
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
- Save Java Object as JSON file using Jackson Library
- Adding Custom ASCII Text Banner in Spring Boot Application
- [Fix] Java: Type argument cannot be of primitive type generics
- List of New Features in Java 11 (JEPs)
- Java: How to Add two Maps with example
- Java JDBC Transition Management using PreparedStatement Examples
- Understanding and Handling NullPointerException in Java: Tips and Tricks for Effective Debugging
- Steps of working with Stored Procedures using JDBCTemplate Spring Boot
- Java 8 java.util.Function and BiFunction Examples
- The Motivation Behind Generics in Java Programming
- Get Current Local Date and Time using Java 8 DateTime API
- Java: Convert Char to ASCII
- Deep Dive: Why avoid java.util.Date and Calendar Classes
More Posts:
- WARNING: Python 2.7 is not recommended [macOS Big Sur] - MacOS
- How to know installed version of Homebrew - MacOS
- Python: Print Dictionary Line by Line Example - Python
- Java equals method - Tutorial - Java
- How to verify if java is installed on the computer and get version detail - Java
- How to List All Users in Linux - Linux
- You're not on Teams yet, but you can set it up for your organization. [Microsoft Teams Login Error] - Microsoft
- Fix Microsoft Windows Update Error 80072EFE - Microsoft