本文整理汇总了Java中javax.servlet.ServletException.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ServletException.printStackTrace方法的具体用法?Java ServletException.printStackTrace怎么用?Java ServletException.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.servlet.ServletException
的用法示例。
在下文中一共展示了ServletException.printStackTrace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
o = (Options) request.getSession().getAttribute("options");
v = (Votes) request.getSession().getAttribute("votes");
response.setContentType("text/html; charset=ISO-8859-1");
request.getSession().setAttribute("options", o);
request.getSession().setAttribute("votes", v);
try {
request.getRequestDispatcher("result.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
response.sendRedirect("error");
}
}
示例2: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
response.setContentType("text/html; charset=ISO-8859-1");
if (haveCookies(request)) {
String fname = findCookies(request, "fname");
String lname = findCookies(request, "lname");
System.out.println("doGet " + fname + " " + fname);
request.getSession().setAttribute("fname", fname);
request.getSession().setAttribute("lname", lname);
}
try {
request.getRequestDispatcher("register.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例3: listAsteroids
import javax.servlet.ServletException; //导入方法依赖的package包/类
/**
* Returns the list of asteroids to iterate over
*
* @return list of asteroids
* @throws ServletException
*/
public ArrayList<Asteroid> listAsteroids() throws ServletException
{
try
{
return db.getAsteroidsFromDatabase();
} catch (ServletException e)
{
e.printStackTrace();
}
return null;
}
示例4: process
import javax.servlet.ServletException; //导入方法依赖的package包/类
/**
* Override process method to catch the infamous BeanUtils.populate exception, which is thrown when a
* session has timed out. The problem is that we can't return a forward from here, so we probably have to
* create a new exception and catch it elsewhere (but where?).
*
* @param request Description of the Parameter
* @param response Description of the Parameter
* @exception ServletException Description of the Exception
* @exception IOException Description of the Exception
*/
public void process(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// prtln("PROCESS");
/*
here is the place (before the request is acted upon by any other class)
to explicitly set the encoding of the request. The is necessary ONLY if
the content-type/charset of the page containing a form has been set to UTF:
<%@ page contentType="text/html; charset=UTF-8" %>
In this case, the input from the form (i.e., the request params) are garbled
if the request encoding is not also set to UTF-8 as below.
NOTE: if the content-type/charset is NOT explicitly set, then setting the request
encoding to UTF-8 as below will also garble the input!!
*/
// set request encoding to UTF-8
try {
request.setCharacterEncoding("UTF-8");
} catch (Throwable t) {
t.printStackTrace();
}
// prtln ("request encoding: " + request.getCharacterEncoding());
try {
super.process(request, response);
} catch (ServletException e) {
prtln("process caught exception: " + e.getMessage());
if ("BeanUtils.populate".equals(e.getMessage())) {
handleBeanUtilsPopulateError(request, response);
}
else {
e.printStackTrace();
throw e;
}
}
}
示例5: setupAndAddTestTomcat
import javax.servlet.ServletException; //导入方法依赖的package包/类
private void setupAndAddTestTomcat(int i) {
Tomcat testTomcat = new Tomcat();
testTomcat.setPort(0);
testTomcat.setBaseDir(testWorkingDir);
Context context;
try {
context = testTomcat.addWebapp(CONTEXT, testWorkingDir);
testTomcat.getEngine().setName("Catalina" + i);
TestServlet testServlet = new TestServlet();
testServlet.setId(i);
testTomcat.addServlet(CONTEXT, "notFoundServlet", new NotFoundServlet());
testTomcat.addServlet(CONTEXT, "timeoutStatusServlet", new TimeoutStatusServlet());
testTomcat.addServlet(CONTEXT, "timeoutingServlet", new SlowTimeoutingServlet());
testTomcat.addServlet(CONTEXT, "restServlet", testServlet);
context.addServletMappingDecoded("/rest/" + ENDPOINT, "restServlet");
context.addServletMappingDecoded("/rest/" + ENDPOINT + "/*", "restServlet");
context.addServletMappingDecoded("/rest/" + NOT_FOUND_ENDPOINT, "notFoundServlet");
context.addServletMappingDecoded("/rest/" + NOT_FOUND_ENDPOINT + "/*", "notFoundServlet");
context.addServletMappingDecoded("/rest/" + TIMEOUT_STATUS_ENDPOINT, "timeoutStatusServlet");
context.addServletMappingDecoded("/rest/" + TIMEOUT_STATUS_ENDPOINT + "/*", "timeoutStatusServlet");
context.addServletMappingDecoded("/rest/" + TIMEOUTING_ENDPOINT, "timeoutStatusServlet");
context.addServletMappingDecoded("/rest/" + TIMEOUTING_ENDPOINT + "/*", "timeoutStatusServlet");
testTomcats.add(testTomcat);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例6: main
import javax.servlet.ServletException; //导入方法依赖的package包/类
public static void main(String[] args) {
DeploymentInfo servletBuilder
= Servlets.deployment()
.setClassLoader(MainVaadin.class.getClassLoader())
.setContextPath(CONTEXT_PATH)
.setDeploymentName("ROOT.war")
.setDefaultEncoding("UTF-8")
.addServlets(
servlet(
MainServlet.class.getSimpleName(),
MainServlet.class).addMapping("/*")
);
DeploymentManager manager = Servlets
.defaultContainer()
.addDeployment(servletBuilder);
manager.deploy();
try {
HttpHandler httpHandler = manager.start();
PathHandler path = Handlers.path(redirect(CONTEXT_PATH))
.addPrefixPath(CONTEXT_PATH, httpHandler);
Undertow undertowServer = Undertow.builder()
.addHttpListener(8080, "0.0.0.0")
.setHandler(path)
.build();
undertowServer.start();
undertow = Result.success(undertowServer);
undertowServer.getListenerInfo().forEach(System.out::println);
} catch (ServletException e) {
e.printStackTrace();
undertow = Result.failure(e.getMessage());
}
}
示例7: writeToScreen
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void writeToScreen(HttpServletRequest req, HttpServletResponse resp, String message,
String mode,
String view, String subview, String url) throws IOException {
xLogger.fine("Entered writeToScreen: view = {0}", view);
resp.setStatus(200);
resp.setContentType("text/html; charset=UTF-8");
message = "<p style=\"font-size:12px;\">" + message + "</p>";
req.setAttribute("message", message);
if (mode != null && !mode.isEmpty()) {
req.setAttribute("mode", mode);
}
if (view != null && !view.isEmpty()) {
req.setAttribute("view", view);
}
if (subview != null && !subview.isEmpty()) {
req.setAttribute("subview", subview);
}
try {
RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
dispatcher.include(req, resp);
} catch (ServletException e) {
xLogger.severe("Exception when writing to screen: {0}", e.getMessage());
e.printStackTrace();
}
xLogger.fine("Exiting writeToScreen");
}
示例8: init
import javax.servlet.ServletException; //导入方法依赖的package包/类
public void init(){
try {
super.init();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例9: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Viser innloggingsskjema med evt. feilmelding.
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getRequestDispatcher("index.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例10: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// Krever at bruker er innlogget!
// Hvis bruker er innlogget vises siden. Hvis ikke sendes bruker til
// innloggingsside med melding om at man må være innlogget for å se
// siden
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getRequestDispatcher("hemmelig.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例11: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=ISO-8859-1");
request.getSession().setAttribute("votes", v);
request.getSession().setAttribute("options", o);
try {
request.getRequestDispatcher("index.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
response.sendRedirect("error");
}
}
示例12: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getRequestDispatcher("error.jsp").include(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例13: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
name = (String) request.getSession().getAttribute("name");
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getSession().setAttribute("name", name);
request.getRequestDispatcher("greetings.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
response.sendRedirect("error");
}
}
示例14: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getRequestDispatcher("index.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}
示例15: doGet
import javax.servlet.ServletException; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html; charset=ISO-8859-1");
try {
request.getRequestDispatcher("error.jsp").forward(request, response);
} catch (ServletException e) {
e.printStackTrace();
}
}