jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes distinguishing between actions at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "distinguishing between actions at runtime" Watch "distinguishing between actions at runtime" New topic
Author

distinguishing between actions at runtime

Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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().


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

@Sagar: it'll also get executed if you visit /SecondAction.do, right?
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

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

Joined: Sep 29, 2008
Posts: 12617

The rest of your answer was right ;)
Stu Johns
Ranch Hand

Joined: Aug 11, 2008
Posts: 63
thanks, I can get info i need off the request, great.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: distinguishing between actions at runtime
 
Similar Threads
No configuration found for the specified action
Standard Action format
Menu update
Maven compilation problem
Multithreading