File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts 2 package name in Interceptor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 package name in Interceptor" Watch "Struts 2 package name in Interceptor" New topic
Author

Struts 2 package name in Interceptor

nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi,

How do I get the name of package in intercetor.

Let's say I have interceptor applied on a package, I can get the name of the action using ActionInvocation class.


Is there any way to get the name of package as well.
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Do you mean namespace? You can get it by requestURI.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

yeah the namespace..

I got it using below code...


Struts 2 ActionConfig class exposes the package name

Thanks
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Your solution is struts2 style i like that.
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

Hi Mohana,

Yes I'm using struts 2. and basically I have two kind of users defined in my application: normal user and super-user

super-user actions are under admin package and normal user are under user package.

and both packages are protected by common Interceptor (AuthenticationInterceptor). There I need the package name to redirect admin users to a different login page.


Thanks
Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

I would like to know why you are not using Roles Interceptor implemented solution is already there why you were doing it again.
nazzy khan
Ranch Hand

Joined: May 06, 2010
Posts: 39

oh is it? I'll look ito that then..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts 2 package name in Interceptor
 
Similar Threads
Struts 1 Plugin ScopeModenDrivenInterceptor Error
Overriding default interceptor stack
struts2: what kicks in first- the interceptors or the form's validation?
Interceptors in Struts 2
problem in field validation