my dog learned polymorphism*
The moose likes Servlets and the fly likes [jsp] classcast excetion 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 » Java » Servlets
Bookmark "[jsp] classcast excetion" Watch "[jsp] classcast excetion" New topic
Author

[jsp] classcast excetion

wessel zaalberg
Greenhorn

Joined: Jul 27, 2001
Posts: 26
What I did was connet a bean I just filled with date to an attribute in the servelt context.
if (hasData)
{ contekst.setAttribute("db_data", naw);
return new ActionRouter("naw-gegevens-page");
}
in the jsp file I have :
<%
ServletContextapp = getServletConfig().getServletContext();
NawGegevens naw = (NawGegevens) app.getAttribute("db_data");
%>
This gives the result ClassCastException.
THe class NawGegevens in in the package beans , in the directory class/beans and that is how the calling class NawGegevensAction can find it.
I am not sure if this path is in the classpath of tomcat, nor would I know how to make this class known.
wessel zaalberg
Greenhorn

Joined: Jul 27, 2001
Posts: 26
I found the solution, it didnot know the type of class so with
<%@ page import="beans.NawGegevens" %>
it is made known.
<%
ServletContextapp = getServletConfig().getServletContext();
NawGegevens naw = (NawGegevens) app.getAttribute("db_data");
%>
I stil prefer a more generic solution, but I 'm glad this works, I get the previously filled data.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: [jsp] classcast excetion
 
Similar Threads
JDBC book suggestions
Any ranchers live in the Dallas/Ft Worth area?
NcNealy steps down...
I need help putting the /bin of my java directory
loading dynamic data