posted 12 years ago
Hi Friends,
I have made a sample program for demonstrating SwitchAction. Folowing is the code snippet.
RegistrationAction
==================
RegistrationForm
===========
struts-config-admin.xml
===============
struts-config.xml
===========
registrationForm.jsp
=============
helloWorld.jsp
=========
index.jsp
======
The flow is like this :
When it find index.jsp then it forwards it to "registration". Here the global forward directs it to "/userSubmit.do" action. It displays the registrationForm.jsp and on clicking the "Submit" button it performs the execute method which return "success". It then sees the path as "path = "/switch.do?page=/listUsers.do&prefix=/admin". Here switch action has already been defined in the action mapping. The 2 parameters which is sends "page=/listUsers.do&prefix=/admin" make the URL as /admin/listUsers.do. It goes to the admin module and attempts to find the action listUsers. Here it forwards the page to be displayed as "helloWorld.jsp". It attempts to find helloWorld.jsp under /admin folder and displays it.
The program performs as expected and prints "Hello World !!!".
Queries :
1. Is my understanding of the flow of SwitchAction correct.?
2. Is that all that was to SwitchAction.
3. What practical use does it have in real life applications ? Is it basically for security purposes ?
Please help me in clearing my doubts and making my concepts crystal clear.
Any help would be highly appreciated.
Thanks and Regards,
Sid.