gpt4 book ai didi

java - Tomcat JSP 错误 500

转载 作者:太空宇宙 更新时间:2023-11-04 13:13:26 25 4
gpt4 key购买 nike

我遇到过这种奇怪的错误,现在我将解释这种情况:基本上我要做的是拥有一个带有简单文本字段和两个按钮的 HTML 表单(或 JSP,并不重要),一个用于提交到 .jsp 页面,另一个只是重置文本字段。一切正常,除非我尝试在文本字段中写一些带空格的东西(例如:“abc 123”)。如果我只是写“abc123”,它不会给出任何错误 500。

我希望你们中的一些人能帮助我,这里是资源:

<html>
<head>`<html>
<head>
<meta charset="ISO-8859-1">
<title>HTML Form</title>
</head>
<body>
<form name = "intoll" method = "post" action = "send.jsp">
Insert text: <input type = "text" name = "food" id = "food">
<br/>
<input type = "submit" name = "send" value = "Send">
<input type = "reset" name = "Reset">
</form>
</body>

发送.jsp:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="com.athirat.intolleranze.foods.*" %>
<%
String food = request.getParameter("food").trim();
if (food != null && food != "") {
food = food.toLowerCase();
out.print(food);
NetMaster.init(food);
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<%
try {
out.print(NetMaster.showContent());
} catch (Exception e) {
throw new Exception("String error");
}
%>
</body>
</html>

谢谢你帮助我。

编辑:堆栈跟踪

giu 16, 2015 3:06:12 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [jsp] in context with path [/intoll] threw exception [An exception occurred processing JSP page /send.jsp at line 22

19: try {
20: out.print(NetMaster.showContent());
21: } catch (Exception e) {
22: throw new Exception("String error");
23: }
24: %>
25: </body>


Stacktrace:] with root cause
java.lang.Exception: Errore nella stringa
at org.apache.jsp.send_jsp._jspService(send_jsp.java:113)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

giu 16, 2015 3:23:56 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [jsp] in context with path [/intoll] threw exception [An exception occurred processing JSP page /send.jsp at line 22

19: try {
20: out.print(NetMaster.showContent());
21: } catch (Exception e) {
22: throw new Exception("String error");
23: }
24: %>
25: </body>


Stacktrace:] with root cause
java.lang.Exception: Errore nella stringa
at org.apache.jsp.send_jsp._jspService(send_jsp.java:113)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

这是 showContent 方法,它被称为方法:

public static String showContent() throws Exception {
if (isFood())
return getContent();
else
return "LOG Creato: " + generateLogFile();
}
private static String generateLogFile() throws Exception {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String logname = "foodLog_" + sdf.format(cal.getTime());
String logdir = ps.getProperty("logfolder");
File f = new File ("." + logdir + logname + ".log");
FileOutputStream fout = new FileOutputStream(f);
DataOutputStream dout = new DataOutputStream(fout);
System.out.println(logname);
System.out.println(logdir);
System.out.println(f.getParent());
dout.writeBytes(food + " non esistente, si prega di aggiungerlo");
fout.close();
return logname;
}
private static String getContent() {
String result = "{[";
@SuppressWarnings("resource")
Scanner sc = new Scanner(inputReader).useDelimiter("\\A");
result += sc.hasNext() ? sc.next() : "";
return result;
}

最佳答案

我解决了:showContent() 抛出一个异常,我只需要捕获它。这个错误是因为我以前在showContent()的try-catch中抛出一个新的异常,由于上面的原因我做不到。谢谢大家。

关于java - Tomcat JSP 错误 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30868685/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com