response object in grails service & redirect from service

630 views
Skip to first unread message

Anand

unread,
Mar 17, 2011, 10:06:17 AM3/17/11
to ig...@googlegroups.com, ig...@googlegroups.com
hi..
        as we all know we can access request object through     
org.springframework.web.context.request.RequestContextHolder.getRequestAttributes().getRequest() 

but how we can access response object nobody has got it using getResponse() ... whats the way out..

second is how we can can redirect(url : "/") in service the way we can do it in controllers.. i want to redirect if the session is invalidated to home page....

plz reply soon help needed...

Yagnesh Chawda

unread,
Mar 17, 2011, 10:48:59 AM3/17/11
to Indian Groovy & Grails User Group
Hi,
Never tried regarding response object part so far. But as far as
redirecting is concerned, its simply bad idea according to me to put
http related activity there inline even if its possible. Service layer
is not really intended for that purpose. Why dont you start sending
special exceptions from service layer back to its caller, and catching
it at controller layer ultimately to discover session invalidation
etc. Infact that should have been tracked b4 you reach service layer
truly speaking, not sure you you are able to reach there as well.

Thanks And Regards,
Yagnesh Chawda.
: http://yagneshchawda.blogspot.com/
: http://twitter.com/yagneshchawda

***************************************************
Good planets are hard to find. Print less!
Save energy to keep your future bright !!
***************************************************
"Earth provides enough to satisfy every man's need,
but not every man's greed." - Mahatma Gandhi
***************************************************
Reply all
Reply to author
Forward
0 new messages