本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}