java - Invalid token in struts -


this code snippet using

if (istokenvalid(request))                  {                     logger.debug("add data owner table");                     system.out.println("add data owner table");                      j=db.addrole(menuform);                      if (j == 1)                         menuform.reset(mapping, request);                     else                         request.setattribute("recordmodifycount", 0);                      message.add("recordmodify", new actionmessage("record.insert", j));                 }                 else                 {                     system.out.println("token not valid add owner");                     logger.debug("token not valid add owner");                      //message.add("recordmodify", new actionmessage("record.insert", 0));                     //forward=mapping.findforward("searchallmenupage");                 } 

this called when click on add button first time click works second , afterwards goes in else block i.e."token not valid add owner" please me why goes in else block.

you need call savetoken() first , struts framework generate token/key in request/session.next time when make request, can check whether token valid or not.once called istokenvalid, need call resettoken() method well.

if (istokenvalid(request)) { ................. ................ resettoken(request); } 

preventing multiple click


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -