• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Something wrong with my application

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I came up with a simple app and have been facing problems. I deliberately created an SQLException so that the ErrorServlet will process it. I ran eclipse in debugging mode and the code runs untill the end of the doPost method and ends with a HTTP 500 error. Can someone tell me why this is happening? I would appreciate it if anyone could take a look at my war file.

web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://localhost/dtd/web-app_2_3.dtd">
<web-app>
<context-param>
<param-name>driverClassName</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<context-param>
<param-name>dbUsername</param-name>
<param-value>****</param-value>
</context-param>
<context-param>
<param-name>dbPassword</param-name>
<param-value>****</param-value>
</context-param>

<listener>
<listener-class>
MyListener
</listener-class>
</listener>


<servlet>
<servlet-name>ErrorServlet</servlet-name>
<servlet-class>chapter04.ErrorServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>chapter04.LoginServlet</servlet-class>
<init-param>
<param-name>dburl</param-name>
<param-value>jdbc:mysql://localhost/test</param-value>
</init-param>
</servlet>

<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>ErrorServlet</servlet-name>
<url-pattern>/error</url-pattern>
</servlet-mapping>

<error-page>
<error-code>403</error-code>
<location>/html/login.html</location>
</error-page>

<error-page>
<exception-type>java.sql.SQLException</exception-type>
<location>/error</location>
</error-page>

</web-app>

ErrorServlet:
package chapter04;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/*
* Created on Mar 26, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/

/**
* @author Me
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ErrorServlet extends HttpServlet{
public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {
doPost(req, res);
}

public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException, ServletException {


}
}
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic