This article describes how to write a first JSP program
1. Configure the server
(1) Select the server view in Eclipse (PS: Many children's shoes say that the server cannot be found because of the version issue of Eclipse, download jee version of Eclipse) and single New Server Wizard hyperlink
(2) Open the Select Server Type list box in the Define a New server interface, expand the Apache node, and select the Tomcat v7.0 server node
(3) Click Next, click the Browse button and select the Tomcat server installation path that you have installed
(4) Click Finish to add a server project in the servers view to start or stop the server
2. Specify a Web browser
Window/preferences/.../web browsers specify a Web browser
3. Write JSP Program
Create a new dynamic Web Project named 1.01, all with the default options.
Create a new JSP file index.jsp under the WebContent node and modify the default code in the Index.jsp file to the following code:
<%@ Page Language="Java"ContentType="text/html; Charset=utf-8"pageencoding="UTF-8"Import="java.util.Date" %><!DOCTYPE HTML><HTML><Head><MetaCharSet=utf-8 "><title>Development of the first JSP Web site</title></Head><Body>Hello, this is my first JSP program<BR>now the time is:<%=New Date(). toLocaleString ()%></Body></HTML>
Run, select "Run on Server"
The following error occurred:
Several ports (8080, 8009) required by Tomcat v7.0 Server at localhost is already in use. The server may already is running in another process, or a system process could be using the port. To start this server you'll need to stop the other process or change the port number (s).
At the command prompt, enter Netstat-aon | findstr 8080
Obtaining the port is occupied by a process with a PID of 2692
Input tasklist |findstr 2692:
Can get the current port is Tomcat7.exe occupied
Continue entering Taskkill-f-im Tomcat7.exe or Taskkill/pid 2692/f
End the process
Start Tomcat normal again in eclipse
The first JSP program