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.
Source: stackoverflow.com
Related Query
- Spring MVC - add cookie inside onBindAndValidate
- java - get cookie value by name in spring mvc
- Spring MVC Form tags: Is there a standard way to add "No selection" item?
- In spring mvc 3, how to write a cookie while returning a ModelAndView?
- how to create a cookie and add to http response from inside my service layer?
- Add secure flag to JSESSIONID cookie in spring automatically
- How do I add Freemarker support to a Spring MVC webapp? Dependency issue?
- How to add a custom security annotation to Spring MVC controller method
- How do I add simple pagination for Spring MVC
- Add rows on table on button click using spring mvc and bind added rows to modelAttribute
- Add tenant dynamically in multitenant database application using Spring MVC and Hibernate
- How to get spring mvc controller model key value inside javascript?
- Spring MVC - Not getting value inside JSP view
- Spring MVC - Calling a rest service from inside another rest service
- Add favicon from Spring MVC
- Add a cookie during the Spring Security login
- How do I add .jsp headers and footers to my Spring MVC web app?
- Use spring mvc xml project inside spring-boot project
- Easiest way to add GWT to a Spring MVC application?
- Spring MVC + DeferredResult add Hateoas stuff
- spring mvc controller - missing cookie named 'xyz'
- Show jsp page inside jar file using Spring MVC
- How to add Object in using model.addAttributes in Spring MVC
- How to Add a Controller in Spring MVC 3?
- How to bind an object inside the list collection of the command object in Spring MVC
- Spring MVC ResponseBodyAdvice for add header in specify return type
- Java Spring MVC doesnt work when I add mvc:resources mapping
- How to add Precall method in Spring MVC Controller
- Using spring:message tag inside of form:input tag in Spring MVC
- Some information about produces attribute inside @RequestMapping in Spring MVC
More Query from same tag
- Java Spring IntelliJ jstl tags doesn't work
- Spring service implementation by environment property
- Multiple transaction in appCtx encountered NoUniqueBeanDefinitionException
- DOJO with spring framework
- Does ModelAndView serialize model before sending response to client
- Spring MVC + Spring Security - Controller Authentication using JSON
- Bind comma-separated string to List
- Adding Path variable changes the view path
- Multiple scheduled-tasks invocation in Spring
- Spring MVC HttpServletRequest request: which button clicked on
- How to map Spring MVC controllers to a specific folder?
- Difference between Spring 4 MVC (servelt 2.5) and Spring 4 MVC (Servlet 3.0) Integrations
- How do i upload/stream large images using Spring 3.2 spring-mvc in a restful way
- Spring Data REST prevent InvalidFormatException
- Versioning resources in REST api
- Jasperreports Spring : Chart is not being displayed when report exported as HTML
- setting setViewName to same JSP page in different controllers in Spring
- Spring4 Security configuration
- Does anyone know how to successfully integrate Seam and Spring MVC?
- getting http 400 bad request spring mvc
- What's the intended use of `servlet-context.xml`, `root-context.xml` and `web.xml`?
- How to mark primary/default constructor in domain layer
- Compressed Spring mvc response and decompressed it back in jquery
- Spring initialise test data in order
- Error converting JDBCConnection to OracleConnection
- Get Security Roles From Weblogic for Spring Security
- Spring + Jackson Content type 'application/json;charset=UTF-8' not supported
- How to get the role for current user with Spring Security
- Spring Context init (java)
- Calling method with null parameters in EL ends up in 0 being passed instead of null