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 :
Output JSP Hello World Program using Eclipse Tomcat Server
More Posts related to Java,
- Convert Java Map Collection Object to JSON String using Jackson
- Java Stream flatmap() Examples
- [Fix] Instant java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Years
- How to run Java Unit Test cases with Apache Maven?
- How to check if Java main thread is alive
- [Fix] java: incompatible types: incompatible parameter types in lambda expression error
- Parsing CSV file using Java code example (Comma Separated File)
- Unhandled exception type InterruptedException : Java Threads
- Native getClass() method from java.lang.Object Class Explained with examples.
- Java Jackson ObjectMapper Class with Examples
- Java 8 Streams map() with examples
- Java 8 - Convert List to Map Examples
- IntelliJ: Error: Could not find or load main class, java.lang.ClassNotFoundException
- Java Stream with Multiple Filters Example
- How to Clear StringJoiner in Java 8
- Spring 5 IoC Example with application Context XML (ClassPathXmlApplicationContext) and Gradle.
- How to get end of line (EOL) or new line character \r \n in Java
- Spring Boot CRUD Examples using JDBCTemplate
- Delete a File in Java with Examples
- Implementing Insertion Sort Algorithm in Java Program
- Java JDBC Batch Update Example with PreparedStatement
- Java JDBC Select Multiple Records from table as List using PreparedStatement
- [Hibernate] The method buildSessionFactory() from the type Configuration is deprecated
- How to fix Java HTTP java.net.UnknownHostException
- Java 8 Display time in 12 hour AM PM format
More Posts:
- Best way to Convert Primitive long to int in Java with some Cautions - Java
- Android Disable EditText from Auto Focus on Activity load - Android
- How to force quit or kill Notepad++ Process - NotepadPlusPlus
- How to show Videos on SharePoint Page - SharePoint
- [fix] docker exec requires at least 2 arguments - Docker
- How to check of Updates on Microsoft Edge Browser on Mac (macOS) - MacOS
- Java JDBC NumberFormatException: For input string - Java
- Change Home Page on Safari for Mac (macOS) - MacOS