File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts 1 Toekn Processing in Ajax Request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 1 Toekn Processing in Ajax Request" Watch "Struts 1 Toekn Processing in Ajax Request" New topic

Struts 1 Toekn Processing in Ajax Request

Mihir K Parekh

Joined: Jul 20, 2012
Posts: 11

I am Using Struts 1.3 in My Application and I have used Struts token methods in my Base Action class for creating new Record. For Example

public class BasicCreateAction extends Action{

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

// process request
// resetToken(request);
// duplicate request simply discard it


in My Application all my Action classes created for Creating Record in Application extends above class and leverage its base functionality.

this works perfectly in the scenario where User explicitly submits forms. in some case the record is created via Ajax Request and not by submitting form. for example,

User wants to create a Product in to application so he presented a product page to create has some fields like Product Name , Number , SKU , and Product Type. the last filed Product Type is separate entity so i have provide option to user to create it by providing Popup menu to create it , in the Popup menu there is a form to create a Product Type. when user press a button on the Popup menu this Product type is created via Ajax Request sent to the server.

so my question is how can i save token for this scenario , so i can i use it in my Action Class as exactly as i can use in previous case ?

in previous case i am saving token from subclass of DispatchAction class where all forwarding of particular page occurs.

Thank You Mihir Parekh
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Struts 1 Toekn Processing in Ajax Request
It's not a secret anymore!