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); }
Comments
Post a Comment