Ad (728x90)

Filled Under: , , ,

What is RequestProcessor, how to extend it?

Controler Learn Struts RequestProcessor Struts Components
RequestProcessor is a class which is used by ActionServlet to maintain the state and process the activities in different level of request lifecycle.

RequestProcessor have following method into it:
1.) processPreprocess - Used to execute line of code before the action servlet start working on any request.
2.) processPostprocess - Used to run snippet after the process method finish its work.

Below is the flow of work for struts with requestprocessor:


Can we create our own RequestProcessor?
Yes, We can create your own RequestProcessor class and can override any of above methods to fulfill the Business requirement.

Add below snippet into Struts-Config.xml

<controller
contentType="text/html;charset=UTF-8"
debug="0"
nocache="true"
processorClass="com.testComp.MyOwnRequestProcess"/>

Create a class with below declaration:

public class MyOwnRequestProcess extends RequestProcessor {

Override your method with given below code:

protected boolean processPreprocess (HttpServletRequest req,HttpServletResponse res){
Add Code here, which will process before process method execute.

You can also override its other method too.

Unknown

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

0 comments:

Post a Comment

Please write to us here...

 

We are featured contributor on entrepreneurship for many trusted business sites:

  • Copyright © Tekhnologia™ is a registered trademark.
    Designed by Templateism. Hosted on Blogger Templates.