Hello WTP
This Tutorial will show you how to create and deploy a simple java web application using Eclipse Web Tools Platform (WTP) and Tomcat Web Server.
Main Learning's
After following this tutorial you will learn how to:
- Download and install WTP
- Create a simple Java web project (html, jsp and Java bean)
- Run a html or a jsp page on the Tomcat server within WTP
- Create a WAR file and deploy it on Tomcat
- Run your simple Java web application in Tomcat
Versions used:
- OS: Windows XP V1.6
- JDK version 1.5.0_12
- Apache Tomcat v 5.5.23
- WTP - Web Tools Platform All-In-One Packages - R2.0 (from June 26, 2007)
Assumptions:
Common Issue:
Tutorial Steps:
1. Go to the WTP download web site:
http://download.eclipse.org/webtools/downloads/
2. Download wtp-all-in-one-sdk-<Your_Platform>.zip
1. e.g. wtp-all-in-one-sdk-win32.zip
3. Create a wtp folder under C:\Program Files\ (or wherever you want)
4. Unzip wtp-all-in-one-sdk-win32.zip to C:\Program Files\wtp

5. Extract to C:\Program Files\wtp

6. Open WTP
1. Double click on C:\Program Files\wtp\eclipse\eclipse.exe
2. Recommendation: create a desktop shortcut to eclipse.exe and rename it to WTP

7. Eclipse WTP

8. Create a Web Project
1. File -> New -> Project…

9. Select Dynamic Web Project
1. Click on Next >

10. Enter the Project name
1. Click on Target Runtime -> New…

11. Select Tomcat 5.5
1. Click on Next >

12. Select the Tomcat installation directory
1. Click on Finish

13. helloWebWorld Project

14. Create a HTML Page

15. Create hello.html

16. hello.html
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor=yellow>
Hello HTML page
</body>
</html>

17. Run hello.html

18. hello.html on WTP and Tomcat. In case you got an error message, please check WTP and Tomcat Installation Issue.

19. Create a hello.jsp

20. hello.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor=green>
Hello JSP World
<br>The current date is <%= new java.util.Date() %>.
</body>
</html>

21. Run hello.jsp

22. hello.jsp on WTP and Tomcat

23. Create a Java Class

24. Enter the Package, enter the Class Name

25. HelloBean
package com.helloweb.model;
public class HelloBean {
public String getGreetings() {
return "Hello Bean World";
}
}

26. Create helloBean.jsp

27. helloBean.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="hello" class="com.helloweb.model.HelloBean">
</jsp:useBean>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body bgcolor=blue>
<jsp:getProperty name="hello" property="greetings" />
</body>
</html>

28. Run helloBean.jsp

29. helloBean.jsp on WTP and Tomcat
30. Create a WAR file

31. Select a Destination
1. Click on Browse…

32. Select <Tomcat_Folder>/webapps folder
1. e.g. C:\Program Files\apache-tomcat-5.5.23\webapps

33. Stop the Tomcat (which is running in WTP)
1. Click on the red square (Stop the server)

34. Start Tomcat
1. Double click on startup.bat

35. Tomcat – console window

36. Tomcat - http://localhost:8080/
37. hello.html is online!
http://localhost:8080/helloWebWorld/hello.html
38. hello.jsp is online!
http://localhost:8080/helloWebWorld/hello.jsp
39. helloBean.jsp is online!
http://localhost:8080/helloWebWorld/helloBean.jsp

Comments (0)
You don't have permission to comment on this page.