You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Maya Muchnik <mm...@pumatech.com> on 2001/02/27 18:07:15 UTC

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.

Maya




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/