Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Interceptors in Struts2

 
Naga Niranjan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to set an attribute in an interceptor with the scope of request to access that in JSP. The follwing code I have used, but that attribute is not getting in JSP.

Interceptor code:

In the above code permissionsList is fetching from a Map, which is in application scope.

JSP code:


Expecting suggestions in this regard.

Niranjan
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Should work, but without the rest of the interceptor code it's hard to say. Is it available in an action?
 
Naga Niranjan
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not available in Action class. The remaining code in that interceptor is checking the session whether it is active or not.
To overcome this problem, temporarly I have used scriplet in JSP as I cannot find any solution yet.

Niranjan.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like I said, should work, but without interceptor code and your configuration I can't really help.

This is *never* appropriate for a scriptlet, though; better to use a Preparable action and get it to the JSP in the action.

(The JSP page is hit through an action, right?)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic