当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletResponse.setLocale方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.setLocale方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.setLocale方法的具体用法?Java HttpServletResponse.setLocale怎么用?Java HttpServletResponse.setLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletResponse的用法示例。


在下文中一共展示了HttpServletResponse.setLocale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 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
 */
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    // Identify the request parameters that we need
    String command = request.getPathInfo();

    String path = request.getParameter("path");
    String installPath = request.getParameter("installPath");
    String installConfig = request.getParameter("installConfig");
    String installWar = request.getParameter("installWar");

    // Prepare our output writer to generate the response message
    response.setContentType("text/html");
    Locale locale = Locale.getDefault();
    response.setLocale(locale);
    PrintWriter writer = response.getWriter();

    // Process the requested command
    if (command == null) {
        response.sendRedirect(request.getRequestURI()+"/list");
    } else if (command.equals("/install")) {
        install(writer, installConfig, installPath, installWar);
    } else if (command.equals("/list")) {
        list(writer, "");
    } else if (command.equals("/reload")) {
        reload(writer, path);
    } else if (command.equals("/remove")) {
        remove(writer, path);
    } else if (command.equals("/sessions")) {
        sessions(writer, path);
    } else if (command.equals("/start")) {
        start(writer, path);
    } else if (command.equals("/stop")) {
        stop(writer, path);
    } else {
        String message =
            sm.getString("managerServlet.unknownCommand", command);
        list(writer, message);
    }

    // Finish up the response
    writer.flush();
    writer.close();
}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:55,代码来源:HTMLManagerServlet.java

示例2: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * 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
 */
public void doGet(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    // Verify that we were not accessed using the invoker servlet
    if (request.getAttribute(Globals.INVOKED_ATTR) != null)
        throw new UnavailableException
            (sm.getString("managerServlet.cannotInvoke"));

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

    // Prepare our output writer to generate the response message
    response.setContentType("text/plain");
    Locale locale = Locale.getDefault();
    response.setLocale(locale);
    PrintWriter writer = response.getWriter();

    // Process the requested command (note - "/deploy" is not listed here)
    if (command == null) {
        writer.println(sm.getString("managerServlet.noCommand"));
    } else if (command.equals("/install")) {
        install(writer, config, path, war);
    } else if (command.equals("/list")) {
        list(writer);
    } else if (command.equals("/reload")) {
        reload(writer, path);
    } else if (command.equals("/remove")) {
        remove(writer, path);
    } else if (command.equals("/resources")) {
        resources(writer, type);
    } else if (command.equals("/roles")) {
        roles(writer);
    } else if (command.equals("/sessions")) {
        sessions(writer, path);
    } else if (command.equals("/start")) {
        start(writer, path);
    } else if (command.equals("/stop")) {
        stop(writer, path);
    } else if (command.equals("/undeploy")) {
        undeploy(writer, path);
    } else {
        writer.println(sm.getString("managerServlet.unknownCommand",
                                    command));
    }

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:67,代码来源:ManagerServlet.java

示例3: doPut

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Process a PUT 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
 */
public void doPut(HttpServletRequest request,
                  HttpServletResponse response)
    throws IOException, ServletException {

    // Verify that we were not accessed using the invoker servlet
    if (request.getAttribute(Globals.INVOKED_ATTR) != null)
        throw new UnavailableException
            (sm.getString("managerServlet.cannotInvoke"));

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

    // Prepare our output writer to generate the response message
    response.setContentType("text/plain");
    Locale locale = Locale.getDefault();
    response.setLocale(locale);
    PrintWriter writer = response.getWriter();

    // Process the requested command
    if (command == null) {
        writer.println(sm.getString("managerServlet.noCommand"));
    } else if (command.equals("/deploy")) {
        deploy(writer, path, request);
    } else {
        writer.println(sm.getString("managerServlet.unknownCommand",
                                    command));
    }

    // Saving configuration
    Server server = ServerFactory.getServer();
    if ((server != null) && (server instanceof StandardServer)) {
        try {
            ((StandardServer) server).store();
        } catch (Exception e) {
            writer.println(sm.getString("managerServlet.saveFail",
                                        e.getMessage()));
        }
    }

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

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:57,代码来源:ManagerServlet.java

示例4: doGet

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Process a GET request for the specified resource.
 *
 * @param request  The servlet request we are processing
 * @param response The servlet response we are creating
 * @throws IOException      if an input/output error occurs
 * @throws ServletException if a servlet-specified error occurs
 */
public void doGet(final HttpServletRequest request,
                  final HttpServletResponse response)
        throws IOException, ServletException {

  // Verify that we were not accessed using the invoker servlet
  if (request.getAttribute(Globals.INVOKED_ATTR) != null) {
    throw new UnavailableException
            (sm.getString("managerServlet.cannotInvoke"));
  }

  // Identify the request parameters that we need
  String command = request.getPathInfo();
  if (command == null) {
    command = request.getServletPath();
  }
  final String config = request.getParameter("config");
  final String path = request.getParameter("path");
  final String type = request.getParameter("type");
  final String war = request.getParameter("war");

  // Prepare our output writer to generate the response message
  final Locale locale = Locale.getDefault();
  final String charset = context.getCharsetMapper().getCharset(locale);
  response.setLocale(locale);
  response.setContentType("text/plain; charset=" + charset);
  final PrintWriter writer = response.getWriter();

  // Process the requested command (note - "/deploy" is not listed here)
  if (command == null) {
    writer.println(sm.getString("managerServlet.noCommand"));
  } else if (command.equals("/install")) {
    install(writer, config, path, war);
  } else if (command.equals("/list")) {
    list(writer);
  } else if (command.equals("/reload")) {
    reload(writer, path);
  } else if (command.equals("/remove")) {
    remove(writer, path);
  } else if (command.equals("/resources")) {
    resources(writer, type);
  } else if (command.equals("/roles")) {
    roles(writer);
  } else if (command.equals("/serverinfo")) {
    serverinfo(writer);
  } else if (command.equals("/sessions")) {
    sessions(writer, path);
  } else if (command.equals("/start")) {
    start(writer, path);
  } else if (command.equals("/stop")) {
    stop(writer, path);
  } else if (command.equals("/undeploy")) {
    undeploy(writer, path);
  } else {
    writer.println(sm.getString("managerServlet.unknownCommand",
            command));
  }

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

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:71,代码来源:ManagerServlet.java

示例5: doPut

import javax.servlet.http.HttpServletResponse; //导入方法依赖的package包/类
/**
 * Process a PUT request for the specified resource.
 *
 * @param request  The servlet request we are processing
 * @param response The servlet response we are creating
 * @throws IOException      if an input/output error occurs
 * @throws ServletException if a servlet-specified error occurs
 */
public void doPut(final HttpServletRequest request,
                  final HttpServletResponse response)
        throws IOException, ServletException {

  // Verify that we were not accessed using the invoker servlet
  if (request.getAttribute(Globals.INVOKED_ATTR) != null) {
    throw new UnavailableException
            (sm.getString("managerServlet.cannotInvoke"));
  }

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

  // Prepare our output writer to generate the response message
  response.setContentType("text/plain");
  final Locale locale = Locale.getDefault();
  response.setLocale(locale);
  final PrintWriter writer = response.getWriter();

  // Process the requested command
  if (command == null) {
    writer.println(sm.getString("managerServlet.noCommand"));
  } else if (command.equals("/deploy")) {
    deploy(writer, path, request);
  } else {
    writer.println(sm.getString("managerServlet.unknownCommand",
            command));
  }

  // Saving configuration
  final Server server = ServerFactory.getServer();
  if (server != null && server instanceof StandardServer) {
    try {
      ((StandardServer) server).store();
    } catch (Exception e) {
      writer.println(sm.getString("managerServlet.saveFail",
              e.getMessage()));
    }
  }

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

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:58,代码来源:ManagerServlet.java


注:本文中的javax.servlet.http.HttpServletResponse.setLocale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。