You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Terje Hopsø <te...@online.no> on 2003/07/07 00:16:06 UTC

ActionForms and errors?

Hello,
 
I am trying to figure out how ActionForm and validate()-function work. If I
returns an error (ActionErrors) from my ActionForm it fail (se below for
output). Returning null everything works fine. I thought that when returning
an error I would return to my loginpage automatically. But I dont. Anyone
who can explain to me hwo this works og give me a link with a fully
functioning example? I have looked at examples but they are for the most
parts of an example.
 
- Terje
 
Error when pressing submit in login.jsp
type Status report

message No input attribute for mapping path /struts/authenticate

description The server encountered an internal error (No input attribute for
mapping path /struts/authenticate) that prevented it from fulfilling this
request.

 
WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
 <filter>
  <filter-name>accessControl</filter-name>
  <filter-class>com.teho.servlets.AccessControlFilter</filter-class>
  <init-param>
   <param-name>loginPage</param-name>
   <param-value>/login.jsp</param-value>
  </init-param>
 </filter>
 <filter-mapping>
  <filter-name>accessControl</filter-name>
  <url-pattern>/internal/*</url-pattern>
 </filter-mapping>
 <servlet>
  <servlet-name>action</servlet-name>
  <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
  <init-param>
   <param-name>application</param-name>
   <param-value>com.teho.servlets.ApplicationResources</param-value>
  </init-param>
 </servlet>
 <servlet-mapping>
  <servlet-name>action</servlet-name>
  <url-pattern>*.do</url-pattern>
 </servlet-mapping>
</web-app>

STRUTS-CONFIG.XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
 <form-beans>
  <form-bean name="loginForm" type="com.teho.servlets.LoginForm" />
 </form-beans>
 <action-mappings>
  <action name="loginForm" type="com.teho.servlets.AuthenticateAction"
path="/struts/authenticate" />
 </action-mappings>
</struts-config>

login.jsp
...
<form name="login" method="post" action="<c:url
value="/struts/authenticate.do" />">
...
 

Re: Action forward to another action without form

Posted by Jing Zhou <ji...@netspread.com>.
----- Original Message ----- 
From: "Sandeep Takhar" <sa...@yahoo.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>; "Jing
Zhou" <ji...@netspread.com>
Sent: Monday, July 07, 2003 12:15 PM
Subject: Re: Action forward to another action without form


> Also important is if you have a different form, the
> properties will be populated according to the old
> submitted parameters.

One way to solve such a problem is what I proposed
the so called Action Controller Delegation Model.
When you *find* the target action mapping according
to an action path, you invoke the execute method on
the action class directly. So the action path of the
target action mapping could become a configurable
parameter in your current action mapping in such model.

Jing

>
> sandeep
> --- Jing Zhou <ji...@netspread.com> wrote:
> > Forwarding to a target action is not considered as a
> > good practice in the past is because the form bean
> > population
> > and validation machineries will be invoked again
> > when
> > Struts process the action (and some more reasons).
> > Of course, if there is no form bean specified in the
> > target
> > action mapping,  it makes sense in such cases.
> >
> > In many use cases, I find people really need
> > *shared* action controllers in their business
> > requirements.
> > The best way to have the functionality is to develop
> > your own action controller delegation model. In such
> > a model, you *find* the target action the same way
> > as
> > Struts *find* it. It is a very simple solution and
> > you
> > could avoid the form bean populations and
> > validations.
> >
> > Jing
> > Netspread Carrier
> > http://www.netspread.com
> >
> > ----- Original Message ----- 
> > From: "Frances Aleah Z. de Guzman"
> > <ad...@ingenium.com.ph>
> > To: "Struts Users Mailing List"
> > <st...@jakarta.apache.org>
> > Sent: Sunday, July 06, 2003 9:41 AM
> > Subject: Re: Action forward to another action
> > without form
> >
> >
> > you can define it to your forward in your
> > struts-config, instead of
> > forwarding
> > it to a page, forward it to an action. but this is
> > not a good practice
> > though.
> >
> > On Monday 07 July 2003 10:31 am, Benjamin Stewart
> > wrote:
> > > Can you point me in the right direction, none of
> > my books talk about it,
> > > cant find examples etc.
> > >
> > > Ben
> > >
> > > Dan Tran wrote:
> > > >Yes;)
> > > >
> > > >
> > > >----- Original Message -----
> > >
> > > From: "Benjamin Stewart"
> > <bs...@waterwerks.com.au>
> > >
> > > >Newsgroups: Struts
> > > >Sent: Sunday, July 06, 2003 6:59 PM
> > > >Subject: Action forward to another action without
> > form
> > > >
> > > >>Greetings,
> > > >> I have a form that submits values. From the
> > Action class I would (in
> > > >>some circumstances) like to go directly to
> > another action class and then
> > > >>forward to a view. Is this possible ?
> > > >>
> > > >>Thanks
> > > >>Ben
> > > >
> > >
> >
> >---------------------------------------------------------------------
> > > >To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > > >For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> > >
> > >
> >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
> > -- 
> > Frances Aleah Z. De Guzman
> > SA/Programmer
> > Ingenium Technology, Inc.
> > http://www.ingenium.com.ph
> >
> > Disclaimer :
> > This message is intended only for the named
> > recipient. If you are not the
> > intended recipient you are notified that disclosing,
> > copying, distributing
> > or taking any action in reliance on the contents of
> > this information is
> > strictly prohibited.
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > struts-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by Sandeep Takhar <sa...@yahoo.com>.
Also important is if you have a different form, the
properties will be populated according to the old
submitted parameters.

sandeep
--- Jing Zhou <ji...@netspread.com> wrote:
> Forwarding to a target action is not considered as a
> good practice in the past is because the form bean
> population
> and validation machineries will be invoked again
> when
> Struts process the action (and some more reasons).
> Of course, if there is no form bean specified in the
> target
> action mapping,  it makes sense in such cases.
> 
> In many use cases, I find people really need
> *shared* action controllers in their business
> requirements.
> The best way to have the functionality is to develop
> your own action controller delegation model. In such
> a model, you *find* the target action the same way
> as
> Struts *find* it. It is a very simple solution and
> you
> could avoid the form bean populations and
> validations.
> 
> Jing
> Netspread Carrier
> http://www.netspread.com
> 
> ----- Original Message ----- 
> From: "Frances Aleah Z. de Guzman"
> <ad...@ingenium.com.ph>
> To: "Struts Users Mailing List"
> <st...@jakarta.apache.org>
> Sent: Sunday, July 06, 2003 9:41 AM
> Subject: Re: Action forward to another action
> without form
> 
> 
> you can define it to your forward in your
> struts-config, instead of
> forwarding
> it to a page, forward it to an action. but this is
> not a good practice
> though.
> 
> On Monday 07 July 2003 10:31 am, Benjamin Stewart
> wrote:
> > Can you point me in the right direction, none of
> my books talk about it,
> > cant find examples etc.
> >
> > Ben
> >
> > Dan Tran wrote:
> > >Yes;)
> > >
> > >
> > >----- Original Message -----
> >
> > From: "Benjamin Stewart"
> <bs...@waterwerks.com.au>
> >
> > >Newsgroups: Struts
> > >Sent: Sunday, July 06, 2003 6:59 PM
> > >Subject: Action forward to another action without
> form
> > >
> > >>Greetings,
> > >> I have a form that submits values. From the
> Action class I would (in
> > >>some circumstances) like to go directly to
> another action class and then
> > >>forward to a view. Is this possible ?
> > >>
> > >>Thanks
> > >>Ben
> > >
> >
>
>---------------------------------------------------------------------
> > >To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > >For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> -- 
> Frances Aleah Z. De Guzman
> SA/Programmer
> Ingenium Technology, Inc.
> http://www.ingenium.com.ph
> 
> Disclaimer :
> This message is intended only for the named
> recipient. If you are not the
> intended recipient you are notified that disclosing,
> copying, distributing
> or taking any action in reliance on the contents of
> this information is
> strictly prohibited.
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by Jing Zhou <ji...@netspread.com>.
Forwarding to a target action is not considered as a
good practice in the past is because the form bean population
and validation machineries will be invoked again when
Struts process the action (and some more reasons).
Of course, if there is no form bean specified in the target
action mapping,  it makes sense in such cases.

In many use cases, I find people really need
*shared* action controllers in their business requirements.
The best way to have the functionality is to develop
your own action controller delegation model. In such
a model, you *find* the target action the same way as
Struts *find* it. It is a very simple solution and you
could avoid the form bean populations and validations.

Jing
Netspread Carrier
http://www.netspread.com

----- Original Message ----- 
From: "Frances Aleah Z. de Guzman" <ad...@ingenium.com.ph>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, July 06, 2003 9:41 AM
Subject: Re: Action forward to another action without form


you can define it to your forward in your struts-config, instead of
forwarding
it to a page, forward it to an action. but this is not a good practice
though.

On Monday 07 July 2003 10:31 am, Benjamin Stewart wrote:
> Can you point me in the right direction, none of my books talk about it,
> cant find examples etc.
>
> Ben
>
> Dan Tran wrote:
> >Yes;)
> >
> >
> >----- Original Message -----
>
> From: "Benjamin Stewart" <bs...@waterwerks.com.au>
>
> >Newsgroups: Struts
> >Sent: Sunday, July 06, 2003 6:59 PM
> >Subject: Action forward to another action without form
> >
> >>Greetings,
> >> I have a form that submits values. From the Action class I would (in
> >>some circumstances) like to go directly to another action class and then
> >>forward to a view. Is this possible ?
> >>
> >>Thanks
> >>Ben
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

-- 
Frances Aleah Z. De Guzman
SA/Programmer
Ingenium Technology, Inc.
http://www.ingenium.com.ph

Disclaimer :
This message is intended only for the named recipient. If you are not the
intended recipient you are notified that disclosing, copying, distributing
or taking any action in reliance on the contents of this information is
strictly prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by "Frances Aleah Z. de Guzman" <ad...@ingenium.com.ph>.
you can define it to your forward in your struts-config, instead of forwarding 
it to a page, forward it to an action. but this is not a good practice 
though.

On Monday 07 July 2003 10:31 am, Benjamin Stewart wrote:
> Can you point me in the right direction, none of my books talk about it,
> cant find examples etc.
>
> Ben
>
> Dan Tran wrote:
> >Yes;)
> >
> >
> >----- Original Message -----
>
> From: "Benjamin Stewart" <bs...@waterwerks.com.au>
>
> >Newsgroups: Struts
> >Sent: Sunday, July 06, 2003 6:59 PM
> >Subject: Action forward to another action without form
> >
> >>Greetings,
> >> I have a form that submits values. From the Action class I would (in
> >>some circumstances) like to go directly to another action class and then
> >>forward to a view. Is this possible ?
> >>
> >>Thanks
> >>Ben
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org

-- 
Frances Aleah Z. De Guzman
SA/Programmer
Ingenium Technology, Inc.
http://www.ingenium.com.ph

Disclaimer :
This message is intended only for the named recipient. If you are not the
intended recipient you are notified that disclosing, copying, distributing
or taking any action in reliance on the contents of this information is
strictly prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by Sandeep Takhar <sa...@yahoo.com>.
just have your forward in the action go to something
the servlet will pick up

<forward name="success" path="/AnotherAction.do"/>

and just

mapping.findForward("success");

Note that this may not be syntatically correct...


sandeep
--- Benjamin Stewart <bs...@waterwerks.com.au>
wrote:
> 
> Can you point me in the right direction, none of my
> books talk about it, 
> cant find examples etc.
> 
> Ben
> 
> Dan Tran wrote:
> 
> >Yes;)
> >
> >
> >----- Original Message ----- 
> >From: "Benjamin Stewart"
> <bs...@waterwerks.com.au>
> >Newsgroups: Struts
> >Sent: Sunday, July 06, 2003 6:59 PM
> >Subject: Action forward to another action without
> form
> >
> >
> >  
> >
> >>Greetings,
> >> I have a form that submits values. From the
> Action class I would (in 
> >>some circumstances) like to go directly to another
> action class and then 
> >>forward to a view. Is this possible ?
> >>
> >>Thanks
> >>Ben
> >>    
> >>
> >
>
>---------------------------------------------------------------------
> >To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> >For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> >
> >  
> >
> 
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> struts-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by Benjamin Stewart <bs...@waterwerks.com.au>.
Can you point me in the right direction, none of my books talk about it, 
cant find examples etc.

Ben

Dan Tran wrote:

>Yes;)
>
>
>----- Original Message ----- 
>From: "Benjamin Stewart" <bs...@waterwerks.com.au>
>Newsgroups: Struts
>Sent: Sunday, July 06, 2003 6:59 PM
>Subject: Action forward to another action without form
>
>
>  
>
>>Greetings,
>> I have a form that submits values. From the Action class I would (in 
>>some circumstances) like to go directly to another action class and then 
>>forward to a view. Is this possible ?
>>
>>Thanks
>>Ben
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: Action forward to another action without form

Posted by Dan Tran <da...@hotmail.com>.
Yes;)


----- Original Message ----- 
From: "Benjamin Stewart" <bs...@waterwerks.com.au>
Newsgroups: Struts
Sent: Sunday, July 06, 2003 6:59 PM
Subject: Action forward to another action without form


> Greetings,
>  I have a form that submits values. From the Action class I would (in 
> some circumstances) like to go directly to another action class and then 
> forward to a view. Is this possible ?
> 
> Thanks
> Ben

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Action forward to another action without form

Posted by Benjamin Stewart <bs...@waterwerks.com.au>.
Greetings,
 I have a form that submits values. From the Action class I would (in 
some circumstances) like to go directly to another action class and then 
forward to a view. Is this possible ?

Thanks
Ben


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org