Tutorial: Java Hello World Application With MyEclipse

Java Hello World Web Application in MyEclipse

1- Open MyEclipse

2- Click on menu File > New > Web Project


clip_image001

3- Give a name to the project. Here I use “Helloworld

clip_image002

4- Click on Finish

5- MyEclipse will automatically create some files. Project hierarchy is show here

clip_image003

6- Open index.jsp. It contains the following code or put the following code in index.jsp


 
 
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+
request.getServerPort()+path+"/";
%>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
 
    <title>My JSP 'index.jsp' starting page</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="keywords" content="keyword1,keyword2,
         keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
 
  <body>
    This is my JSP page. <br>
  </body>
</html>
 


7- The only line of code for our interest is following


 
 
  <body>
    This is my JSP page.
  </body>
 


8- The other file of your interest is web.xml. Open the file and <welcome-file> tag should point to index.jsp

 
 
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
 


9- That’s it, no more coding and now we will deploy the web application on tomcat web server.

10- I am using MyEclipse 7.5, Tomcat is already configured with the IDE and you just need to run the server and your application is ready.

clip_image004

11- Tomcat is running now

12- Open browser and navigate to following URL http://localhost:8080/Helloworld/

clip_image005

13- That’s it, your first java web application is up and running.

Downloads

Download the full project from here

Enjoy!





Related Links

Java/JSP Hello World Web Application in Eclipse

Written by ali on December 17, 2009 under J2EE, Tutorials.

Comments

No Comments

Add a Comment

* means field is required.

Name *

Mail *

Website