在尽我最大努力解决错误的过程中,我需要您的帮助来找到所遇到的错误的解决方案。
错误(在控制台中显示)是:
严重:适用于Servlet [servlet.RegisterServlet]中的Servlet.service() 路径为[/ Company_Mailer_System]的上下文抛出异常 java.io.FileNotFoundException:请求的资源[/Company_Mailer_System/header.html]在以下位置不可用 org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:797) 在 org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:454) 在 org.apache.catalina.servlets.DefaultServlet.doPost(DefaultServlet.java:547) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:660)在 org.apache.catalina.servlets.DefaultServlet.service(DefaultServlet.java:434) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:741)处 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在 org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:712) 在 org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:580) 在 org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:516) 在servlet.RegisterServlet.doPost(RegisterServlet.java:24)处 javax.servlet.http.HttpServlet.service(HttpServlet.java:660)在 javax.servlet.http.HttpServlet.service(HttpServlet.java:741)在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在 org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 在 org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) 在 org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) 在 org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:651) 在 org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 在 org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) 在 org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:412) 在 org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 在 org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:754) 在 org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1385) 在 org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 在java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源) 在 org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(未知来源)
我的代码如下:
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/RegisterServlet")
public class RegisterServlet extends HttpServlet
{
public void doPost(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
{
response.setContentType("text/html");
PrintWriter out=response.getWriter();
request.getRequestDispatcher("header.html").include(request,
response);
String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String gender=request.getParameter("gender");
String dob=request.getParameter("dob");
String addressLine=request.getParameter("addressLine");
String city=request.getParameter("city");
String state=request.getParameter("state");
String country=request.getParameter("country");
String contact=request.getParameter("contact");
int status=dao.RegisterDao.save(name, email+"@cmailer.com", password, gender, dob, addressLine, city, state, country, contact);
if(status>0)
{
out.print("<p>You are successfully registered!</p>");
request.getRequestDispatcher("Login.html").include(request, response);
}
else
out.print("<p>You are successfully not registered!</p>");
request.getRequestDispatcher("footer.html").include(request, response);
}}
header.html文件如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<style type="text/css">
.inputform{float:left;
width:400px;border:1px solid pink;border-radius:10px;padding:10px;
}
.inputform table tr td input,textarea,select{width:200px;}
#gender1,#gender2{width:10px;}
#submit{margin-left:100px;width:100px;}
#reset{width:100px;}
.design{background-color:red;color:white;padding-left:100px;}
</style>
<body>
<!-- header -->
<h2>Company Mailer</h2>
<h3 style="background-color:red;color:red;">c</h3>
<!-- body -->
</body>
</html>
先谢谢您。