This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso 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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "where to write the code for intercepts" Watch "where to write the code for intercepts" New topic

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,
David Newton

Joined: Sep 29, 2008
Posts: 12617

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

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

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

or set

<result name="error" type="redirectAction">

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

to process exceptions.

Struts 2 tutorial
It is sorta covered in the JavaRanch Style Guide.
subject: where to write the code for intercepts