aspose file tools*
The moose likes Struts and the fly likes Getting name of servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting name of servlet" Watch "Getting name of servlet" New topic
Author

Getting name of servlet

O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Is there a way i can find out the name of the Action Path that triggers a specific Action?

For example if my struts-config.xml had the following entry..



How can i from the ViewCustomerAction determine the action path (i.e. viewCustomer)?

I have tried this.getClass but its returning the name of the class. I need the name of the path in the url.

Thanks

[ May 08, 2006: Message edited by: O. Ziggy ]
[ May 08, 2006: Message edited by: O. Ziggy ]
Joseph Erickson
Greenhorn

Joined: May 05, 2006
Posts: 10
In your servlet, try:



What you want is probably in the ActionMapping, if this isn't what you were looking for. Since the servlet can actually be mapped to many different Actions, the servlet itself won't know where it came from.

Why do you need to know the Action the servlet is being called from? Debugging? You probably shouldn't have specific functionality tied to which mapping your servlet is using. I would break these out into specific Action classes if you are.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

This is a Struts question, moving to the Struts forum.

Dave.
O. Ziggy
Ranch Hand

Joined: Oct 02, 2005
Posts: 430

Originally posted by Joseph Erickson:
In your servlet, try:



What you want is probably in the ActionMapping, if this isn't what you were looking for. Since the servlet can actually be mapped to many different Actions, the servlet itself won't know where it came from.

Why do you need to know the Action the servlet is being called from? Debugging? You probably shouldn't have specific functionality tied to which mapping your servlet is using. I would break these out into specific Action classes if you are.


Do you think its better if i use the class name and determine from that what Action was executed?
Joseph Erickson
Greenhorn

Joined: May 05, 2006
Posts: 10
If you want to know what Action was executed, mapping.getPath() is the way to go. I just wondered why you needed to know.

There's a lot of good data you can get about how your action was called from the ActionMapping object that gets passed into your execute() method. Might help you with what you're doing.

http://struts.apache.org/struts-action/struts-core/apidocs/org/apache/struts/config/ActionConfig.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting name of servlet