This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes where to write the code for intercepts Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "where to write the code for intercepts" Watch "where to write the code for intercepts" New topic
Author

where to write the code for intercepts

Aditi Gandy
Ranch Hand

Joined: Apr 23, 2008
Posts: 37
Hi, I am new to Struts and wanted to know how to make example of Helloworld in Struts2 stateless and where to write the code for intercepts?

Can anyone please help me?


Thanks & Regards,
Author
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It's not clear to me what you're asking.
Stephanie Dutcheson
Greenhorn

Joined: Dec 07, 2008
Posts: 17
You define interceptor in struts.xml
<interceptors>
<interceptor name="authentication" class="com.onepd.struts2.lesson.action.Authentication"/>
<interceptor-stack name="secureStack">
<interceptor-ref name="authentication"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
</interceptors>

implements Interceptor in say Authentication class, method intercept()
will do all job.

or set

<global-results>
<result name="error" type="redirectAction">
...
</result>
</global-results>

<global-exception-mappings>
<exception-mapping exception="java.lang.Exception" result="error"/>
</global-exception-mappings>

to process exceptions.

-----
Struts 2 tutorial
http://www.onepd.com
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: where to write the code for intercepts
 
Similar Threads
where to write session related code
Detecting Servlet timeout using ajax/post.
Where Do I Create Session, Set Attribute, etc. In Struts?
Caching rendered html in jsp
Changing the value of a rich:comboBox