1 Dynamic Web Project Important:
Before running project, you need to stop other tomcat application:
a) External, Run>services.msc, then stop Tomcat(if it’s started).
b) Internal, Click the Stop Tomcat icon (tomcat plugins in Eclipse)
使用 Eclipse 建立 Dynamic Web Project (File>New>Project>Web>Dynamic Web Project).
如:HelloProject.
Index.jsp is Under WebContent. 清单 1. index.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>My Title</title>
</head>
<body>
<% java.util.Date d = new java.util.Date(); %>
<h1>
Today's date is <%= d.toString() %> and this jsp page worked!
</h1>
</body>
</html>
2 TomcatProject Important:
Before running project, you need to stop other tomcatapplication:
Clickthe StopTomcat icon (if it’s started)
Youcan see the status of the servers as below.
如图:在Eclipse中选择新建一个项目,其中选择tomcat project. (File>New>Poroject>Java>TomcatProject).
然后点击下一步,输入项目名字,点下一步,
出现下一个项目设定的画面,如图
点击完成按钮
然后打开eclipse左边的project,可以看到建立的servlet项目已经出现了
如图