我按照教程开始了一个关于Java EE的项目,使用Eclipse。 在一段时间内,一切都是正确的,我可以毫无问题地访问我的主页。
但是从今天下午开始我尝试加载页面时遇到错误,请参阅我的HttpServlet.doGet()。遵循代码和错误:
package fr.tricv.servlets;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import fr.tricv.beans.DataUserBean;
import fr.tricv.utils.Definer;
public class HomeServlet extends HttpServlet {
private static final long serialVersionUID = -7005932622678943062L;
private static final String VIEW = "/WEB-INF/index.jsp";
//public static final String VIEW_SUCCESS = "/WEB-INF/home.jsp";
private String res = "";
private Map<String, String> errors = new HashMap<String, String>();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.getServletContext().getRequestDispatcher(VIEW).forward(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
boolean flagLogged = true;
//HttpSession session = request.getSession();
String email = request.getParameter(Definer.CHAMP_ID);
String password = request.getParameter(Definer.CHAMP_MDP);
/*
DataUserBean user = new DataUserBean();
user.setEmail(email);
user.setPassword(password);
try {
Definer.validationEmail( user.getEmail() );
} catch ( Exception e ) {
setError( Definer.CHAMP_MDP, e.getMessage() );
flagLogged = false;
}
switch (Definer.checkUser(user)) {
case -1:
res = "Utilisateur non existant ou email invalide.";
flagLogged = false;
break;
case 0:
break;
case 1:
break;
default:
flagLogged = false;
}
// Process & test
request.setAttribute("user", user);
request.setAttribute("result", res);
request.setAttribute("errors", errors);
*/
if (flagLogged && errors.isEmpty()) {
//session.setAttribute(Definer.ATT_SESSION_USER, user);
//this.getServletContext().getRequestDispatcher(VIEW_SUCCESS).forward(request, response);
} else {
//session.setAttribute(Definer.ATT_SESSION_USER, null);
this.getServletContext().getRequestDispatcher(VIEW).forward(request, response);
}
}
private void setError(String champMdp, String message) {
errors.put( champMdp, message );
}
}
JSP文件:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="CSS/general.css" />
<title>Consort NT : Tri CV</title>
</head>
<body>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed"
data-toggle="collapse" data-target="#navbar" aria-expanded="false"
aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span
class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> <img id="nav_logo"
src="img/logonav.png"></a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
</ul>
</div>
<!--/.nav-collapse -->
</div>
</div>
<div class="container">
<div class="starter-template">
<p class="lead row"></p>
<div class="row">
<h1 class="col-md-12">Tri CV : Login</h1>
<form method="post" action="<c:url value="/triCV"/>"
class="col-md-12">
<fieldset class="col-md-12 login">
<legend>Veuillez vous connecter :</legend>
<div class="row login_line">
<div class="input-group col-md-offset-4 col-md-4 login_input">
<span class="input-group-addon" id="basic-addon1">@</span> <input
type="text" id="email" name="email"
value="<c:out value="${user.email}"/>" class="form-control"
placeholder="Email" aria-describedby="basic-addon1" />
</div>
<span class="error">${errors['email']}</span>
</div>
<div class="col-md-offset-2 col-md-8 separator"></div>
<div class="row login_line">
<div class="input-group col-md-offset-4 col-md-4 login_input">
<span class="input-group-addon" id="basic-addon1"> {-} </span> <input
type="password" id="password" name="password" value=""
class="form-control" placeholder="MDP"
aria-describedby="basic-addon1" />
</div>
<span class="error">${errors['password']}</span>
</div>
<div class="col-md-offset-2 col-md-8 separator_end"></div>
<div class="row login_line">
<input type="submit"
class="btn btn-default col-md-offset-3 col-md-2"
value="Connexion" /> <input type="reset"
class="btn btn-default col-md-offset-2 col-md-2"
value="Remise à zéro" />
</div>
<p class="${empty erreurs ? 'success' : 'error'}">${result}</p>
</fieldset>
</form>
</div>
</div>
</div>
<!-- /.container -->
<!--
<p>
<c:out value="${title}" />
<br/>
<c:out value="${dataBean.name}" />
<c:set target="${dataBean}" property="name" value="CAFFREY" />
<c:out value="${dataBean.name}" />
<br/>Accusations : <br/>
<c:forEach items="${dataBean.skills}" var="skill" varStatus="state">
<div><c:out value="${state.index} : ${skill}" /></div>
</c:forEach>
</p>
<p>
<c:url value="www.google.com">
<c:param name="dude">google</c:param>
</c:url>
</p>
-->
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
</body>
</html>
最后是web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>TriCV</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>HomeServlet</servlet-name>
<servlet-class>fr.tricv.servlets.HomeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HomeServlet</servlet-name>
<url-pattern>/triCV</url-pattern>
</servlet-mapping>
</web-app>
错误:
INFOS: Server startup in 574 ms
juin 15, 2016 4:22:23 PM org.apache.catalina.core.ApplicationDispatcher invoke
GRAVE: "Servlet.service()" pour la servlet jsp a lancé une exception
javax.servlet.jsp.JspTagException
at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:216)
at org.apache.jsp.WEB_002dINF.index_jsp._jspx_meth_c_005fset_005f0(index_jsp.java:328)
at org.apache.jsp.WEB_002dINF.index_jsp._jspService(index_jsp.java:212)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at fr.tricv.servlets.HomeServlet.doGet(HomeServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
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)
juin 15, 2016 4:22:23 PM org.apache.catalina.core.StandardWrapperValve invoke
GRAVE: Servlet.service() for servlet [HomeServlet] in context with path [/TriCV] threw exception [javax.servlet.ServletException: javax.servlet.jsp.JspTagException] with root cause
javax.servlet.jsp.JspTagException
at org.apache.taglibs.standard.tag.common.core.SetSupport.doEndTag(SetSupport.java:216)
at org.apache.jsp.WEB_002dINF.index_jsp._jspx_meth_c_005fset_005f0(index_jsp.java:328)
at org.apache.jsp.WEB_002dINF.index_jsp._jspService(index_jsp.java:212)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:747)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:485)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:410)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:337)
at fr.tricv.servlets.HomeServlet.doGet(HomeServlet.java:27)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:624)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:436)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
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)
我首先搜索其他帖子,但似乎我没有找到解决方案,很多帖子都谈到NPE或CNF,但这不是我的例外,实际上是指“.forward()”。 ..
是的,有人能帮帮我吗? :)提前致谢