HostManagerServlet.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:apache-tomcat-7.0.73-with-comment 作者:
/**
 * Process a GET request for the specified resource.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are creating
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet-specified error occurs
 */
@Override
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    StringManager smClient = StringManager.getManager(
            Constants.Package, request.getLocales());

    // Identify the request parameters that we need
    String command = request.getPathInfo();
    if (command == null)
        command = request.getServletPath();
    String name = request.getParameter("name");

    // Prepare our output writer to generate the response message
    response.setContentType("text/plain; charset=" + Constants.CHARSET);
    PrintWriter writer = response.getWriter();

    // Process the requested command
    if (command == null) {
        writer.println(sm.getString("hostManagerServlet.noCommand"));
    } else if (command.equals("/add")) {
        add(request, writer, name, false, smClient);
    } else if (command.equals("/remove")) {
        remove(writer, name, smClient);
    } else if (command.equals("/list")) {
        list(writer, smClient);
    } else if (command.equals("/start")) {
        start(writer, name, smClient);
    } else if (command.equals("/stop")) {
        stop(writer, name, smClient);
    } else {
        writer.println(sm.getString("hostManagerServlet.unknownCommand",
                                    command));
    }

    // Finish up the response
    writer.flush();
    writer.close();

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号