You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by faith ok <x_...@yahoo.com> on 2000/05/12 00:57:00 UTC
Error: 500. How to escape this page
Hi, appiciate your response.
I use apache 1.3.12, tomcat 3.1, JDK 1.3 in NT 4.0
In servlet code, if the page have err, how to escape
it? I set the "ErrorDocument 500 /err.html"
in httpd.conf, but it is not work, the customer
browser still get the follow message.
Error: 500
Location: /jaguar/servlet/classifieds_broad
Internal Servlet Error:
java.lang.NullPointerException
at
classifieds_broad.service(classifieds_broad.java:76)
at
javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
ClassCastException accessing loaded servlet from JSP
Posted by Edward Demetrio Pacheco <ed...@melior.com>.
I'm hoping someone can help me with an odd problem: I've set up a db
connection pool servlet that is loaded on startup. In that servlet, I am
using the setAttribute() method of the ServletContext to allow the servlet
itself to be accessed as an application object. From another servlet, I am
able to access this connection pool servlet with no problem. However, if I
try to do the same from a JSP page, I get a ClassCastException error. See the
code snippets below for more info...
Thanks.
======================
Code in connection pool servlet
======================
// Context attribute key
public static String KEY = "javaservlets.db.ConnectionServlet_21";
.
.
// Add this servlet to the context so that other servlets
// can find it
getServletContext().setAttribute(KEY, this); // this is in the init() of the
servlet itself
===================================================
Code in a different servlet that uses the connection pool servlet (this works)
===================================================
// Get the ConnectionServlet that holds the
// connection pool
ServletConfig config = getServletConfig();
ServletContext context = config.getServletContext();
Object o = context.getAttribute(ConnectionServlet_21.KEY);
if (o == null) {
throw new ServletException("ConnectionServlet not started");
}
ConnectionServlet_21 conServlet = (ConnectionServlet_21) o;
=================================
Code in JSP file that causes ClassCastException
=================================
javaservlets.db.ConnectionServlet_21 conServlet = null;
synchronized (application) {
conServlet = (javaservlets.db.ConnectionServlet_21)
pageContext.getAttribute("javaservlets.db.ConnectionServlet_21",PageContext.APPLICATION_SCOPE);
// ^ I believe this is the line it has the problem with. It
can get the application attribute, but can't cast it...
if ( conServlet == null ) {
throw new ServletException("ConnectionServlet not started");
}
}
Also, using the code that works from the servlet in the JSP likewise fails
with the ClassCastException.