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,
- [Fix] java.time.zone.ZoneRulesException: Unknown time-zone ID
- Parse XML file in Java using DOM Parser
- Java equals method - Tutorial
- [Program] How to read three different values using Scanner in Java
- Java: The value of the local variable string is not used
- Display Output in Java Console as a Table
- How to detect Operating System using Java code
- Java 8 Streams map() with examples
- [Fix] java: incompatible types: incompatible parameter types in lambda expression error
- Add newline character Java code example (\r \n \r\n)
- List of Java Major Minor Version Numbers
- IntelliJ Keyboard Shortcut to remove unused imports [Java]
- Java - Check if array contains the value
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- How to declare and initialize Array in Java Programming
- [Solved] com.sun.xml.ws.transport.http.servlet.WSServletContextListener ClassNotFoundException
- XmlRpcException ConnectException connection refused error
- Create a Zip file using Java Code programmatically
- List of jar files for Jax-ws (SOAP) based Java Web Services
- How to fix Java HTTP java.net.UnknownHostException
- List of jars required for Struts2 project
- [fix] java: incompatible types: double cannot be converted to java.lang.Integer Generics
- Maven BUILD FAILURE: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin
- Get the current timestamp in Java
- java: unclosed string literal [Error]
More Posts:
- How to Gzip a file directory on Mac OS X using Terminal Command - Mac-OS-X
- [Solved] Mic not working on iPhone 7 after iOS 14 upgrade - Apple
- Setting up Cloud feature with Notepad++ - NotepadPlusPlus
- Find Mac version using terminal command - MacOS
- Unable to connect to the Internet : Google Chrome - Chrome
- Enable Spellcheck in eclipse workspace - Eclipse
- ls command sort by file size [Linix/UNIX/macOS/bash] - Linux
- How to enable line numbers in IntelliJ - HowTos