hi i'm cameron mackenzie at cameron mcnz on twitter i wanted to give you a couple of
debugging strategies and show you how to use some of the debugging tools that are built
into apache struts so to take advantage of the debugging facilities that are available to your
struts applications one of the first things you want to do is make sure you've turned the struts
dev mode on now a lot of tutorials will show you how to do that inside of the struts.xml file but
i like to stick with the zero configuration type of environment as much as possible which means
setting that right in the web.xml file setting your struts filter to say hey we are in dev mode
struts.def mode true as i said i like doing that in this web.xml file a lot better than doing it
in the struts config i don't like having a struts config at all and i don't have one in this project
now this is going to allow the debug interceptor to be turned on which is cool we'll take a look
at that in a minute the other thing i like to have in terms of doing debugging is the apache
struts browser config plug-in and in order to get that you've got a you got to go into your
maven palm file and add a dependency and i'm adding the dependency for the struts config
browser plug-in after doing that's always a good idea to just update your maven configuration so
i'll update the project just make sure that that jar file is downloaded and available locally
and with that done well i'm going to do a couple of things the first thing i'm going to do
is i'm going to make it possible to call up the configuration browser when i click on a link so
i'm going to go into my register.jsp file and that's this one that represents this here so
right under right under where it says trigger an exception i'm just looking for that i'm going
to have this here that says lunch the browser configuration so i'll do a couple of breaks there
and now with this particular link in here going to the register action which everything goes
to register action but turning the config browser on when i go to the register action
i'll be able to do some debugging and see some information about that particular action
component so why don't i run that program click on the register run as run on server
i'll click display that in french so it looks nice and then i'll click this launch
the configuration browser option and when you see launch the configuration browser option coming up
you see this gives us the opportunity to go in and debug some of our different action classes
i've got three bad call display and register so you can take a look at register gives you
some of the different paths that we have for input success and for error gives you the location of it
you can go in take a look at bad calls show you some of the information as well so that's kind
of cool that gives you some information about the various actions that you have in your class and
where they root to now i've only got one register action here so this isn't all that exciting
but i'm sure if you pull up your own projects that have hundreds of action classes in them it
might look a little bit more interesting than mine but i think that's cool nevertheless um
take a look config browser show constants all sorts of fantastic information in here as well
now the other thing that i configured was the ability to go in and take a look at
our actions through the browser and so i've got the debug browser plugin so i'm going to do this
i'm going to call in my display actions one of the actions that i have but because i've set
the dev environment to true i can pull up this browser so i'll click on the browser here
and you can see it's giving me all sorts of information about the display
action right in my browser so it gives me the locale gives me information about the
request gives me information about the action and that's how you can work with some of the built-in
debugging features of struts and there you go that's how easy it is to debug some of your
apache structs applications or at least give you some tools to start debugging it anyways
now if you enjoyed this tutorial why don't you head over to the serverside.com i'm the editor
in chief over there we've got lots of great tutorials on struts and spring and hibernate
and anything to do with enterprise software development especially in the java realm if you're
interested in my personal antics you can follow me on twitter at cameronmcnz and subscribe on youtube