score:0

well it turns out that i still can't find any intuitive, built-in ways to do this from within spring mvc 2.5.

so what i ended up doing is this hack. first i modified my controllers to invoke a utility function class that would take the resulting service object (wherever it may be invoked), which exposes a servlet compatible getcookie() method and then placed that under the user's session like so:

webutils.setsessionattribute(request, "myresponseobjectsessionname", myresponseobject);

now, since they all inherit from simpleformcontroller, i instead created a new abstract class which still inherits from the former, but has a modified handlerequestinternal() method, like so:

public modelandview handlerequestinternal(httpservletrequest request, httpservletresponse response) throws exception {

    // let the controller do it's job
    modelandview result = handlerequestinternal(request, response, errors);

    // and then use a helper class to inspect the session, find the session attribute
    // 'myresponseobjectsessionname', and set any cookies left in case it does exist at 
    // this point in time.
    new processserviceobject().setserviceresponsecookie(request, response);

    return result;
}

not very elegant but i think it works. cheers.


Related Query

More Query from same tag