本文整理匯總了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();
}