You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by christian reichlin <cr...@viviance.com> on 2001/01/30 17:24:23 UTC

parameters for actions

hi,

im looking for an easy way to "configure" actions.

for using reusable actions it would be great if there is a possibility 
to give parameters to a specific action. (if possible in the 
action.xml/struts-config.xml).
one example is a reusable signup action where one parameter defines 
which form fields (name, e-mail) are necessary/ mandatory.
it should be possible to use one action more times with differently 
configured parameters in one webapp.

i didn't found something like this one the stuts pages, can someone tell 
me if something similar like this already exist or if something like 
this will be added in future or if this is something stupid and 
shouldn't be solved this way.

cheers,
christian


Re: struts-example - handle of ServletException

Posted by Maya Muchnik <mm...@pumatech.com>.
Thank you, Peter. So many good implementations around!

Peter Alfors wrote:

> We wrap errors in our own exception class, and store them in our request/session.
> Then redirect the user to a standard error page that knows how to retrieve the
> error from the request/session, and display it in a 'friendly' way to the user.
> Our exception class contains a user message, as well as the actuall error.  The
> standard error page displays the user message with a link to an 'error details'
> page that displays the actual error, stack trace, etc (for developers, admins,
> etc).
>
> This allows your errors to be localized as well.  :)
>
> Pete
>
> Maya Muchnik wrote:
>
> > Thank you.
> > I thought, that some struts "magic" I can use. If I will use a standard
> > "errorPage" as you suggest, I will lose all pluses of the good struts
> > interface.
> > Maya
> >
> > Jean-Noël Ribette wrote:
> >
> > > ----- Original Message -----
> > > From: Maya Muchnik <mm...@pumatech.com>
> > > To: <st...@jakarta.apache.org>
> > > Sent: Tuesday, February 27, 2001 5:07 PM
> > > Subject: struts-example - handle of ServletException
> > >
> > > > Hi,
> > > > Do you have any ideas how registration.jsp file (struts-example) can be
> > > > changed to handle a situation when a user call it directly. I do not
> > > "like" a
> > > > SevletException to be displayed:
> > > >
> > > > Error: 500
> > > > Location: /struts-example/registration.jsp
> > > > Internal Servlet Error:
> > > >
> > > > javax.servlet.ServletException: No bean found under attribute key
> > > > registrationForm.....A LOT OF ERRORS MESSAGES
> > > >
> > > > It is better to display some "friendly" error message or return to
> > > login.jsp.
> > > >
> > >
> > > Hi Maya,
> > >
> > > You can specify a defaut error page in case you get a exception in your page
> > > using the <%@ page errorPage="myErrorPage.jsp" %> tag. If an error occurs in
> > > the JSP, the user is send to this page. Have a look at the jsp spec for more
> > > details.
> > >
> > > Jean-Noël


Re: struts-example - handle of ServletException

Posted by Peter Alfors <pe...@irista.com>.
We wrap errors in our own exception class, and store them in our request/session.
Then redirect the user to a standard error page that knows how to retrieve the
error from the request/session, and display it in a 'friendly' way to the user.
Our exception class contains a user message, as well as the actuall error.  The
standard error page displays the user message with a link to an 'error details'
page that displays the actual error, stack trace, etc (for developers, admins,
etc).

This allows your errors to be localized as well.  :)

Pete

Maya Muchnik wrote:

> Thank you.
> I thought, that some struts "magic" I can use. If I will use a standard
> "errorPage" as you suggest, I will lose all pluses of the good struts
> interface.
> Maya
>
> Jean-Noël Ribette wrote:
>
> > ----- Original Message -----
> > From: Maya Muchnik <mm...@pumatech.com>
> > To: <st...@jakarta.apache.org>
> > Sent: Tuesday, February 27, 2001 5:07 PM
> > Subject: struts-example - handle of ServletException
> >
> > > Hi,
> > > Do you have any ideas how registration.jsp file (struts-example) can be
> > > changed to handle a situation when a user call it directly. I do not
> > "like" a
> > > SevletException to be displayed:
> > >
> > > Error: 500
> > > Location: /struts-example/registration.jsp
> > > Internal Servlet Error:
> > >
> > > javax.servlet.ServletException: No bean found under attribute key
> > > registrationForm.....A LOT OF ERRORS MESSAGES
> > >
> > > It is better to display some "friendly" error message or return to
> > login.jsp.
> > >
> >
> > Hi Maya,
> >
> > You can specify a defaut error page in case you get a exception in your page
> > using the <%@ page errorPage="myErrorPage.jsp" %> tag. If an error occurs in
> > the JSP, the user is send to this page. Have a look at the jsp spec for more
> > details.
> >
> > Jean-Noël

Re: struts-example - handle of ServletException

Posted by Maya Muchnik <mm...@pumatech.com>.
Thank you.
I thought, that some struts "magic" I can use. If I will use a standard
"errorPage" as you suggest, I will lose all pluses of the good struts
interface.
Maya

Jean-Noël Ribette wrote:

> ----- Original Message -----
> From: Maya Muchnik <mm...@pumatech.com>
> To: <st...@jakarta.apache.org>
> Sent: Tuesday, February 27, 2001 5:07 PM
> Subject: struts-example - handle of ServletException
>
> > Hi,
> > Do you have any ideas how registration.jsp file (struts-example) can be
> > changed to handle a situation when a user call it directly. I do not
> "like" a
> > SevletException to be displayed:
> >
> > Error: 500
> > Location: /struts-example/registration.jsp
> > Internal Servlet Error:
> >
> > javax.servlet.ServletException: No bean found under attribute key
> > registrationForm.....A LOT OF ERRORS MESSAGES
> >
> > It is better to display some "friendly" error message or return to
> login.jsp.
> >
>
> Hi Maya,
>
> You can specify a defaut error page in case you get a exception in your page
> using the <%@ page errorPage="myErrorPage.jsp" %> tag. If an error occurs in
> the JSP, the user is send to this page. Have a look at the jsp spec for more
> details.
>
> Jean-Noël


Re: struts-example - handle of ServletException

Posted by Jean-Noël Ribette <je...@improve.fr>.
----- Original Message -----
From: Maya Muchnik <mm...@pumatech.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, February 27, 2001 5:07 PM
Subject: struts-example - handle of ServletException


> Hi,
> Do you have any ideas how registration.jsp file (struts-example) can be
> changed to handle a situation when a user call it directly. I do not
"like" a
> SevletException to be displayed:
>
> Error: 500
> Location: /struts-example/registration.jsp
> Internal Servlet Error:
>
> javax.servlet.ServletException: No bean found under attribute key
> registrationForm.....A LOT OF ERRORS MESSAGES
>
> It is better to display some "friendly" error message or return to
login.jsp.
>

Hi Maya,

You can specify a defaut error page in case you get a exception in your page
using the <%@ page errorPage="myErrorPage.jsp" %> tag. If an error occurs in
the JSP, the user is send to this page. Have a look at the jsp spec for more
details.

Jean-Noël


Re: struts-example - handle of ServletException

Posted by Maya Muchnik <mm...@pumatech.com>.
Thank you Incze. This is the 3rd or 4th good suggestions!!! We have so many gurus.
The Life is good.
Maya

Incze Lajos wrote:

> On Tue, Feb 27, 2001 at 12:07:15PM -0500, Maya Muchnik wrote:
> > Hi,
> > Do you have any ideas how registration.jsp file (struts-example) can be
> > changed to handle a situation when a user call it directly. I do not "like" a
> > SevletException to be displayed:
> >
> > Error: 500
> > Location: /struts-example/registration.jsp
> > Internal Servlet Error:
> >
> > javax.servlet.ServletException: No bean found under attribute key
> > registrationForm.....A LOT OF ERRORS MESSAGES
> >
> > It is better to display some "friendly" error message or return to login.jsp.
> >
> > Maya
> >
> To avoid situations when a user targets directly to view page I see
> three strategies:
>
> 1. Take all your view pages under WEB-INF.
> 2. Use container managed security and disable access to directories
>    where your view pages reside (thes will be available only for
>    servlet dispather's forwarding/including).
> 3. Place a logic at the start of your view pages which checks the
>    calling URL and redirects/forwards to the appropriate controler
>    action.
>
> Each of them has their odds but couldn't find a better solution so far.
>                                                               incze


Re: struts-example - handle of ServletException

Posted by Incze Lajos <in...@mail.matav.hu>.
On Tue, Feb 27, 2001 at 12:07:15PM -0500, Maya Muchnik wrote:
> Hi,
> Do you have any ideas how registration.jsp file (struts-example) can be
> changed to handle a situation when a user call it directly. I do not "like" a
> SevletException to be displayed:
> 
> Error: 500
> Location: /struts-example/registration.jsp
> Internal Servlet Error:
> 
> javax.servlet.ServletException: No bean found under attribute key
> registrationForm.....A LOT OF ERRORS MESSAGES
> 
> It is better to display some "friendly" error message or return to login.jsp.
> 
> Maya
> 
To avoid situations when a user targets directly to view page I see
three strategies:

1. Take all your view pages under WEB-INF.
2. Use container managed security and disable access to directories
   where your view pages reside (thes will be available only for
   servlet dispather's forwarding/including).
3. Place a logic at the start of your view pages which checks the
   calling URL and redirects/forwards to the appropriate controler
   action.

Each of them has their odds but couldn't find a better solution so far.
                                                              incze

Re: struts-example - handle of ServletException

Posted by Maya Muchnik <mm...@pumatech.com>.
Thank you, David.

David Winterfeldt wrote:

> You can always add some logic tags at the top of the
> registration.jsp to check if he is logged in, certain
> objects are in scope that the form needs, etc.  If the
> criteria aren't met, forward him to any page you want
> and display a message.  You could also forward it to
> an error.do page that could create a struts error
> message that could be displayed on a page with the
> html:errors tag.
>
> David
>
> --- Maya Muchnik <mm...@pumatech.com> wrote:
> > Hi,
> > Do you have any ideas how registration.jsp file
> > (struts-example) can be
> > changed to handle a situation when a user call it
> > directly. I do not "like" a
> > SevletException to be displayed:
> >
> > Error: 500
> > Location: /struts-example/registration.jsp
> > Internal Servlet Error:
> >
> > javax.servlet.ServletException: No bean found under
> > attribute key
> > registrationForm.....A LOT OF ERRORS MESSAGES
> >
> > It is better to display some "friendly" error
> > message or return to login.jsp.
> >
> > Maya
> >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/


Re: struts-example - handle of ServletException

Posted by David Winterfeldt <dw...@yahoo.com>.
You can always add some logic tags at the top of the
registration.jsp to check if he is logged in, certain
objects are in scope that the form needs, etc.  If the
criteria aren't met, forward him to any page you want
and display a message.  You could also forward it to
an error.do page that could create a struts error
message that could be displayed on a page with the
html:errors tag.

David

--- Maya Muchnik <mm...@pumatech.com> wrote:
> Hi,
> Do you have any ideas how registration.jsp file
> (struts-example) can be
> changed to handle a situation when a user call it
> directly. I do not "like" a
> SevletException to be displayed:
> 
> Error: 500
> Location: /struts-example/registration.jsp
> Internal Servlet Error:
> 
> javax.servlet.ServletException: No bean found under
> attribute key
> registrationForm.....A LOT OF ERRORS MESSAGES
> 
> It is better to display some "friendly" error
> message or return to login.jsp.
> 
> Maya
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

struts-example - handle of ServletException

Posted by Maya Muchnik <mm...@pumatech.com>.
Hi,
Do you have any ideas how registration.jsp file (struts-example) can be
changed to handle a situation when a user call it directly. I do not "like" a
SevletException to be displayed:

Error: 500
Location: /struts-example/registration.jsp
Internal Servlet Error:

javax.servlet.ServletException: No bean found under attribute key
registrationForm.....A LOT OF ERRORS MESSAGES

It is better to display some "friendly" error message or return to login.jsp.

Maya




Re: parameters for actions

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
christian reichlin wrote:

> hi,
>
> im looking for an easy way to "configure" actions.
>

One general approach to this comes from the fact that you can subclass the
ActionMapping class with your own, which could then include some additional
properties.  Then, you could say:

    <action className="com.mycompany.MyActionMapping
      path="/...">
        <parameter name="requiredFields" value="....."/>
    </action>

Now, when your action's perform() method is called, a reference to the
ActionMapping is passed, and you can call:

    String requiredFields =
      ((MyActionMapping) mapping).getRequiredFields();


> christian

Craig