JAVA_HOME=c:/j2sdk1.4.2
classpath=.;
%JAVA_HOME%/lib/dt.jar;
%JAVA_HOME%/lib/tools.jar;
(.;一定不能少,因为它代表当前路径)
path=%JAVA_HOME%/bin
|
public class Test
{
public static void main(String args[])
{
System.out.println("This is a test program.");
}
}
|
javac Test.java
java Test
|
CATALINA_HOME
:c:/tomcat
CATALINA_BASE
:c:/tomcat
TOMCAT_HOME: C:/Tomcat
|
classpath=.;
%JAVA_HOME%/lib/dt.jar;
%JAVA_HOME%/lib/tools.jar;
%CATALINA_HOME%/common/lib/servlet.jar;
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.
//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>My Web Application
</display-name>
<description>
A application for test.
</description>
</web-app>
|
<html><body><center>
Now time is: <%=new java.util.Date()%>
</center></body></html>
|
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
{
public void doGet(HttpServletRequest request,
HttpServletResponse response)th
rows ServletException,IOException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><head><title>");
out.println("This is my first Servlet");
out.println("</title></head><body>");
out.println("<h1>Hello,World!</h1>");
out.println("</body></html>");
}
}
|
ROOT/index.html
ROOT/welcom.jsp
|
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
|
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
|
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
|
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping>
|