Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

distinguishing between actions at runtime

 
Stu Johns
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have 2 actions
a1 and a2 that map the the same struts action,
In the execute method i need to be able to determine which action has been selected, how can i do this?
(the action has no form.)

thanks

Stu
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you define two action mapping url to the same action class, in that case, the first mapping in struts-config.xml will executes !!

Like,



Here, "MyAction" gets executed from URL /FirstAction.do..

To check from which URL its coming from, use HttpServletRequest#getRequestURI().
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Sagar: it'll also get executed if you visit /SecondAction.do, right?
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:@Sagar: it'll also get executed if you visit /SecondAction.do, right?


Ohh, Yes David, you are right.. I don't whats going through my mind when I posted such an idiot reply.. :banghead:

Actually I interpret question wrong , I thought poster ask like, If same action path mapped to two different Action class, then which action class get executed ?

I'm sorry.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The rest of your answer was right ;)
 
Stu Johns
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, I can get info i need off the request, great.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic