Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting name of servlet

 
O. Ziggy
Ranch Hand
Posts: 430
Android Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a Struts question, moving to the Struts forum.

Dave.
 
O. Ziggy
Ranch Hand
Posts: 430
Android Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic