Hallo Leute, ich arbeite aktuell an einem Uni- Projekt, doch leider komme ich nicht weiter...
Ich habe eine LoginView, LoginAppl, UserBean und MySqlAccess
LoginView:
LoginAppl:
UserBean:
MySqlAccess
Sobald ich das ausführe und auf "Login" klicke, egal ob die Daten Stimmen oder nicht, kommt immer Fehler:
HTTP Status 500 - java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
Ich habe eine LoginView, LoginAppl, UserBean und MySqlAccess
LoginView:
HTML:
<div class="container">
<div class="row row-centered">
<div class="col-md-4 col-md-offset-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Bitte Loggen Sie sich ein!</h3>
</div>
<div class="panel-body">
<form accept-charset="UTF-8" role="form" action="./LoginAppl.jsp" method="get">
<fieldset>
<div class="form-group">
<input class="form-control" placeholder="Benutzername (E-Mail)" name="email" type="email">
</div>
<div class="form-group">
<input class="form-control" placeholder="Passwort" name="password" type="password" value="">
</div>
<div class="checkbox">
<label>
<input name="remember" type="checkbox" value="Remember Me"> Remember Me
</label>
</div>
<input class="btn btn-lg btn-success btn-block" type="submit" name ="login" value="Login">
<hr/>
<input class="btn btn-lg btn-facebook btn-block" type="submit" name = "zurreg" value="Account Anfordern">
</fieldset>
</form>
</div>
</div>
</div>
</div>
</div>
LoginAppl:
HTML:
<%! public String denullify(String s){
return (s==null)?"":s;
} %>
<%
String email = request.getParameter("email");
String password = request.getParameter("password");
String login = this.denullify(request.getParameter("login"));
String zurreg = this.denullify(request.getParameter("zurreg"));
if (login.equals("Login")){
user.setEmail(email);
user.setPassword(password);
boolean emailPwExists = false;
try{
emailPwExists = user.checkEmailPassword();
}catch (Exception e){
e.printStackTrace();
msg.setSystemfehler();
response.sendRedirect("./LoginView.jsp");
}
if(emailPwExists){
user.setAngemeldet(true);
msg.setPortalWelcome();
response.sendRedirect("./StartseiteAppl.jsp?comeFrom=LoginAppl");
}else{
msg.setUserDoesNotExist();
response.sendRedirect("./LoginView.jsp");
}
}else if (zurreg.equals("Account Anfordern")){
// hier evtl. noch Msg setzen
response.sendRedirect("./RegAppl.jsp");
}else{
// hier evtl. noch Msg setzen
response.sendRedirect("./LoginView.jsp");
}
%>
UserBean:
Code:
public boolean checkEmailPassword() throws ClassNotFoundException, SQLException{
// prüfen Sie, ob this.userid UND this.password in der Tabelle USER vorkommt
// true - ja, kommt vor; false - nein, userid / pw-Kombi ist falsch
String sql = "SELECT * FROM TEST.USER WHERE EMAIL = ? AND PASSWORD = ?";
System.out.println(sql);
Connection dbConn = new DB2Access().getConnection();
PreparedStatement prep = dbConn.prepareStatement(sql);
prep.setString(1, this.email);
prep.setString(2, this.password);
ResultSet dbRes = prep.executeQuery();
return dbRes.next();
}
MySqlAccess
Code:
package de.hs_lu.bw.jdbc;
import java.sql.SQLException;
public class DB2Access extends JDBCAccess {
public DB2Access() throws SQLException, ClassNotFoundException {
super();
}
public void setDBParms(){
dbDrivername = "com.mysql.jdbc.Driver";
dbURL = "jdbc:mysql://localhost/test";
dbUser = "root";
dbPassword = "123456";
}
public static void main(String[] args) throws SQLException, ClassNotFoundException{
new DB2Access();
}
}
Sobald ich das ausführe und auf "Login" klicke, egal ob die Daten Stimmen oder nicht, kommt immer Fehler:
HTTP Status 500 - java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
Code:
SELECT * FROM TEST.USER WHERE EMAIL = ? AND PASSWORD = ?
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at de.hs_lu.bw.jdbc.JDBCAccess.createConnection(JDBCAccess.java:31)
at de.hs_lu.bw.jdbc.JDBCAccess.<init>(JDBCAccess.java:18)
at de.hs_lu.bw.jdbc.DB2Access.<init>(DB2Access.java:8)
at beans.UserBean.checkEmailPassword(UserBean.java:111)
at org.apache.jsp.jsp.LoginAppl_jsp._jspService(LoginAppl_jsp.java:161)
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:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
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:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
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)
Okt 03, 2016 12:35:31 PM org.apache.catalina.core.StandardWrapperValve invoke
SCHWERWIEGEND: Servlet.service() for servlet [jsp] in context with path [/SchulApp] threw exception [java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed] with root cause
java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
at org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:494)
at org.apache.jsp.jsp.LoginAppl_jsp._jspService(LoginAppl_jsp.java:174)
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:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
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:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
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)