This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Something wrong with my application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Something wrong with my application" Watch "Something wrong with my application" New topic
Author

Something wrong with my application

Hui Ge
Greenhorn

Joined: Mar 11, 2005
Posts: 25
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 {


}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Something wrong with my application
 
Similar Threads
Complete web.xml file in XML format
Problem with FORM authentication method
Problem deploying-accesing a single servlet webapp in Tomcat 5
prb from Hemant Deshmukh...
Class LoginServlet not a Servlet?