You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Al...@divintech.com on 2002/11/06 03:45:49 UTC
Extending ActionMapping in Struts 1.1 - classcast exception.
I am working on an app with Tomcat 4.1 and Struts 1.1. I would like to
extend an ActionMapping, in order to verify that the user is logged in. I
extend an ActionMapping, create the getter and setter methods for the
property that I have added.
Finally, I change my web.xml and my struts-config.xml files as indicated
below. However, in my execute ( ...) method, when I cast the ActionMapping
parameter to a UsersActionMapping, I get a ClassCastException. It seems
that for some reason it is disregarding the fact that I want it to pass an
UserActionMapping object , and instead passes me a regular ActionMapping
object. If comment out the cast to UsersActionMapping, the execute method
executes successfully..
So, my question is.. what am I missing.. what else do I have to do in
order to get an instance of an UserActionMapping object in my execute
method, instead of getting the normal ActionMapping object... ?
Thanks in advance...
---- web.xml excerpt ---
.........
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>5</param-value>
</init-param>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>ApplicationResources</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>printrejects.UsersActionMapping</param-value>
</init-param>
<init-param>
<param-name>application</param-name>
<param-value>printrejects.ApplicationResources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
.......
-------- struts-config.xml excerpt - - - -
....
<action path="/ClaimList"
type="printrejects.ClaimListAction"
scope="request">
<set-property property="loginRequired" value="true" />
<forward name="success" path="/claimslist.jsp" />
</action>
............
----------- ClaimListAction.java excerpt ...
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
String target = "success";
UsersActionMapping uam = (UsersActionMapping)mapping;
.............
Thanks,
Alex Kotchnev
Diversified Information Technologies