You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Lawlor <fr...@athensgroup.com> on 2001/12/06 21:37:02 UTC

Question/Issue with "forward" specifications

In my code I had accidentally typed:
   return mapping.findForward("succcess");

(note the 3 c's)

Instead of getting a runtime error my app just went
nowhere?

1) why doesn't findForward() throw an exception
rather than returning null?

2) more generally, I am concerned about errors
that you cannot discover until runtime and then
only by ensuring you have tested every possible
situation.

One of the important things about Java is the
emphasis on catching things at compile time.
It would be good in the design of Struts to keep
some focus on allowing error detection at 
compile time, or at least at application init.

In the above case for example, there may be some way to
use static constants rather than strings.  It would
be good to look at some of the other Struts elements.

This may not seem like a big deal to some people,
but I remember well the 'bad old days' of maintaining
applications with interpreted code.  Runtime discovery
of bugs is a bad characteristic for quality apps.

"Introspect, don't interpret".

Frank Lawlor
Athens Group, Inc.
(512) 345-0600 x151
Athens Group, an employee-owned consulting firm integrating technology
strategy and software solutions.




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Question/Issue with "forward" specifications

Posted by Keith Bacon <ke...@yahoo.com>.
Hi gurus!
I use helper methods that log a warning when a null is
returned - makes it easy to track down errors.
Q1 - Is this good practice? I suspect I'm replicating
logging that struts already has.
Q2 - Are there problems with such methods being
static(will they be a bottleneck)?

Frank - your concern about run-time errors is very
true. I was thinking of using logical names with a
prefix (say gfd=Global Forwards, fbn=Form Bean) so I
can scan my source code & compare the results with my
config file. Not hi-tech & breaches the java standard
of having nice clean names but if I get one more time
waster caused by a mis-match of names I might start
doing it). Just occured to me that it'll help me  find
unused things as well.
Keith.


--- Ted Husted <hu...@apache.org> wrote:
> Frank Lawlor wrote:
> > 1) why doesn't findForward() throw an exception
> > rather than returning null?
> 
> Conceptually, not finding something in response to
> what could be a
> dynamic query is not an exceptional event. A SQL
> query returns an empty
> set all the time. Its up to the application to
> decide what to do about
> that.
> 
> As we explore doing more with exception handling in
> an Action, it may be
> a good idea to add alternative methods that threw an
> exception instead
> of return null (but without changing the existing
> API). Please feel free
> to enter this to Bugzilla as an enhancement request.
> 
> In the meantime, if you feel that it should throw an
> exception, then I
> would recommend subclassing ActionMappings and
> adding a method that
> called findForward and threw the exception of your
> choice if it returned
> null. Another way to go, would be to add a helper
> method to a base
> Action class that did the same thing.
> 
> 
> > 2) more generally, I am concerned about errors
> > that you cannot discover until runtime and then
> > only by ensuring you have tested every possible
> > situation.
> > 
> > One of the important things about Java is the
> > emphasis on catching things at compile time.
> > It would be good in the design of Struts to keep
> > some focus on allowing error detection at
> > compile time, or at least at application init.
> >
> > In the above case for example, there may be some
> way to
> > use static constants rather than strings.  It
> would
> > be good to look at some of the other Struts
> elements.
> 
> I don't believe that there is a way to require
> developers to use String
> constants, although I known many developers do. And
> even if we could,
> the constant couldn't be imported in an XML file,
> where it would do the
> most good. I'm not saying using String contstants
> for fowards isn't a
> good idea. I do it myself. But it's not a panacea.
> 
> After all, even if the constant exists, a Java
> compiler can't tell if it
> is the "right" constant. And there are plenty of
> other errors that a
> Java compiler will never ever catch. Even if you get
> the name of the
> forward right, there's no guarantee that the path
> associated with it is
> any good, and won't return a 404. 
> 
> > This may not seem like a big deal to some people,
> > but I remember well the 'bad old days' of
> maintaining
> > applications with interpreted code.  Runtime
> discovery
> > of bugs is a bad characteristic for quality apps.
> > 
> > "Introspect, don't interpret".
> 
> I'm just afraid this is a fundamental aspect of
> writing Web applications
> that support outside components, like JavaServer
> Pages or Velocity
> templates. Introspecting whether these components
> exist, or whether the
> right one is being called, is outside the scope of a
> Java compiler.
> 
> In order to solve other problems, all of the Struts
> components are put
> into wrappers that encapsulate implementation detail
> behind a logical
> name. This is very powerful feature that makes it
> possible to keep the
> components loosely coupled. We can change a global
> forward in the
> configuration file, and have that change reflected
> in a JavaServer Page
> and in an Action, without recompiling either one.
> But, at the same time,
> we can't guarantee that the change makes any sense,
> or leads to a valid
> path, or any number of things. And since these
> changes can be made
> without recompiler, there is no way for a compiler
> to even think about
> checking them ;-(
> 
> I think in real life the only practical solution is
> to realize that
> runtime testing of Web applications is an essential
> part of development,
> and that tools like Cactus and StrutsTestCase have
> to as much a part of
> our environment as Ant and Jikes.
> 
> One very cool tool is the StrutsResourceChecker 
> 
> http://husted.com/struts/resources/checker.html
> 
> What would be very neat would be something like this
> that could analyze
> the configuration file and check all the links, like
> the Web site link
> checkers do. This could lay the groundwork for
> something that
> introspected the Action, and checked to see if the
> forwards went
> someplace. 
> 
> 
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Question/Issue with "forward" specifications

Posted by Ted Husted <hu...@apache.org>.
Frank Lawlor wrote:
> 1) why doesn't findForward() throw an exception
> rather than returning null?

Conceptually, not finding something in response to what could be a
dynamic query is not an exceptional event. A SQL query returns an empty
set all the time. Its up to the application to decide what to do about
that.

As we explore doing more with exception handling in an Action, it may be
a good idea to add alternative methods that threw an exception instead
of return null (but without changing the existing API). Please feel free
to enter this to Bugzilla as an enhancement request.

In the meantime, if you feel that it should throw an exception, then I
would recommend subclassing ActionMappings and adding a method that
called findForward and threw the exception of your choice if it returned
null. Another way to go, would be to add a helper method to a base
Action class that did the same thing.


> 2) more generally, I am concerned about errors
> that you cannot discover until runtime and then
> only by ensuring you have tested every possible
> situation.
> 
> One of the important things about Java is the
> emphasis on catching things at compile time.
> It would be good in the design of Struts to keep
> some focus on allowing error detection at
> compile time, or at least at application init.
>
> In the above case for example, there may be some way to
> use static constants rather than strings.  It would
> be good to look at some of the other Struts elements.

I don't believe that there is a way to require developers to use String
constants, although I known many developers do. And even if we could,
the constant couldn't be imported in an XML file, where it would do the
most good. I'm not saying using String contstants for fowards isn't a
good idea. I do it myself. But it's not a panacea.

After all, even if the constant exists, a Java compiler can't tell if it
is the "right" constant. And there are plenty of other errors that a
Java compiler will never ever catch. Even if you get the name of the
forward right, there's no guarantee that the path associated with it is
any good, and won't return a 404. 

> This may not seem like a big deal to some people,
> but I remember well the 'bad old days' of maintaining
> applications with interpreted code.  Runtime discovery
> of bugs is a bad characteristic for quality apps.
> 
> "Introspect, don't interpret".

I'm just afraid this is a fundamental aspect of writing Web applications
that support outside components, like JavaServer Pages or Velocity
templates. Introspecting whether these components exist, or whether the
right one is being called, is outside the scope of a Java compiler.

In order to solve other problems, all of the Struts components are put
into wrappers that encapsulate implementation detail behind a logical
name. This is very powerful feature that makes it possible to keep the
components loosely coupled. We can change a global forward in the
configuration file, and have that change reflected in a JavaServer Page
and in an Action, without recompiling either one. But, at the same time,
we can't guarantee that the change makes any sense, or leads to a valid
path, or any number of things. And since these changes can be made
without recompiler, there is no way for a compiler to even think about
checking them ;-(

I think in real life the only practical solution is to realize that
runtime testing of Web applications is an essential part of development,
and that tools like Cactus and StrutsTestCase have to as much a part of
our environment as Ant and Jikes.

One very cool tool is the StrutsResourceChecker 

http://husted.com/struts/resources/checker.html

What would be very neat would be something like this that could analyze
the configuration file and check all the links, like the Web site link
checkers do. This could lay the groundwork for something that
introspected the Action, and checked to see if the forwards went
someplace. 


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: struts - weblogic service pack 10

Posted by John Ng <jn...@yahoo.com>.
Have anyone tried to get the struts running under sp
10? 

Thanks
John

--- John Ng <jn...@yahoo.com> wrote:
> Hi, we would like to upgrade our weblogic server
> from
> sp8 to sp10.  We are using wlssp8-struts.jar in our
> sp8 environmet to get our struts stuff working. 
> However, it does not work for sp10.  Is there any
> struts service packs that we need to install for
> sp10
> to work with struts?
> 
> Thanks
> John
> 
> __________________________________________________
> Do You Yahoo!?
> Send your FREE holiday greetings online!
> http://greetings.yahoo.com
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 


__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


struts - weblogic service pack 10

Posted by John Ng <jn...@yahoo.com>.
Hi, we would like to upgrade our weblogic server from
sp8 to sp10.  We are using wlssp8-struts.jar in our
sp8 environmet to get our struts stuff working. 
However, it does not work for sp10.  Is there any
struts service packs that we need to install for sp10
to work with struts?

Thanks
John

__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>