Search in sources :

Example 26 with StringManager

use of org.apache.tomcat.util.res.StringManager in project tomcat by apache.

the class HTMLHostManagerServlet method doPost.

/**
 * Process a POST 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 doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    StringManager smClient = StringManager.getManager(Constants.Package, request.getLocales());
    // Identify the request parameters that we need
    String command = request.getPathInfo();
    String name = request.getParameter("name");
    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);
    String message = "";
    // Process the requested command
    if (command == null) {
    // No command == list
    } else if (command.equals("/add")) {
        message = add(request, name, smClient);
    } else if (command.equals("/remove")) {
        message = remove(name, smClient);
    } else if (command.equals("/start")) {
        message = start(name, smClient);
    } else if (command.equals("/stop")) {
        message = stop(name, smClient);
    } else if (command.equals("/persist")) {
        message = persist(smClient);
    } else {
        // Try GET
        doGet(request, response);
    }
    list(request, response, message, smClient);
}
Also used : StringManager(org.apache.tomcat.util.res.StringManager)

Example 27 with StringManager

use of org.apache.tomcat.util.res.StringManager in project tomcat by apache.

the class HTMLHostManagerServlet method doGet.

// --------------------------------------------------------- Public Methods
/**
 * 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();
    // Prepare our output writer to generate the response message
    response.setContentType("text/html; charset=" + Constants.CHARSET);
    String message = "";
    // Process the requested command
    if (command == null) {
    // No command == list
    } else if (command.equals("/list")) {
    // Nothing to do - always generate list
    } else if (command.equals("/add") || command.equals("/remove") || command.equals("/start") || command.equals("/stop") || command.equals("/persist")) {
        message = smClient.getString("hostManagerServlet.postCommand", command);
    } else {
        message = smClient.getString("hostManagerServlet.unknownCommand", command);
    }
    list(request, response, message, smClient);
}
Also used : StringManager(org.apache.tomcat.util.res.StringManager)

Aggregations

StringManager (org.apache.tomcat.util.res.StringManager)27 PrintWriter (java.io.PrintWriter)9 IOException (java.io.IOException)8 ContextName (org.apache.catalina.util.ContextName)8 Context (org.apache.catalina.Context)6 Manager (org.apache.catalina.Manager)6 UnknownHostException (java.net.UnknownHostException)5 DistributedManager (org.apache.catalina.DistributedManager)4 Session (org.apache.catalina.Session)4 ServletException (jakarta.servlet.ServletException)3 Writer (java.io.Writer)3 InetAddress (java.net.InetAddress)3 ArrayList (java.util.ArrayList)2 Locale (java.util.Locale)2 Scanner (java.util.Scanner)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ServletException (javax.servlet.ServletException)2 Container (org.apache.catalina.Container)2 ServletContext (jakarta.servlet.ServletContext)1 HttpSession (jakarta.servlet.http.HttpSession)1