• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SwitchAction Query

 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic