1

我编写了一个简单的 HelloServlet,如下所示。

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class HelloServlet
 */
@WebServlet("/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.setContentType("text/html");
        PrintWriter out = response.getWriter();
        String docType =
        "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
        "Transitional//EN\">\n";
        out.println(docType +
        "<HTML>\n" +
        "<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
        "<BODY BGCOLOR=\"#FDF5E6\">\n" +
        "<H1>Hello</H1>\n" +
        "</BODY></HTML>");
    }

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

}

我在 Eclipse 的 Java EE 透视图中安装了 GlassFish 3.1。每当我尝试运行 servlet 并单击服务器上的“在服务器上运行”时,它会出现以下消息:

此域需要在启动域之前设置管理密码。请指定管理密码。启动域需要主密码。没有控制台,没有提示可能。您应该使用 --savemasterpassword=true 创建域或使用 --passwordfile 选项提供密码文件。

命令启动域失败。

glassfish 始终有一个默认的主密码“changeit”。为什么它提示我这条消息?

在此处输入图像描述

4

0 回答 0