Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[jsp] classcast excetion

 
wessel zaalberg
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic