论坛里搜了很多帖子,但是还不是很清楚。
如果单独的运行http://localhost:8080/HelloWorld/helloservlet是可以显示的。
<%@ 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>Index</title>
</head>
<body>
<% java.util.Date d = new java.util.Date();
int i=1;%>
<h1>
Today's date is <%= d.toString() %> and this jsp page worked!
and i =<%=++i %>
<p>
<a href ="com/example/servlets/helloservlet">I am servlet</a>
</h1>
</body>
</html>package com.example.servlets;import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;/**
 * Servlet implementation class helloservlet
 */
public class helloservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public helloservlet() {
        super();
        // TODO Auto-generated constructor stub
    } /**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().write("hello servlet");

} /**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
 */
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}}