I am using Jodd Madvoc
MVC Framework. I want to get IP address of web application client. How can I get HttpServletRequest
object in action class?
@MadvocAction(value = "login")
public class LoginAction extends BaseAction {
Logger logger = LoggerFactory.getLogger(getClass());
@PetiteInject
UserService userService;
@Action
public void view() {
if (logger.isInfoEnabled())
logger.info("LoginAction.view()");
// Code for getting ip Address
forwardTo("/login.jsp");
}
}
After reading http://jodd.org/doc/madvoc/injection.html like HttpServletResponse
injection I have done the same for HttpServletRequest
.
@MadvocAction(value = "login")
public class LoginAction extends BaseAction {
Logger logger = LoggerFactory.getLogger(getClass());
@PetiteInject
UserService userService;
@In(scope = ScopeType.SERVLET)
protected HttpServletResponse servletResponse;
@In(scope = ScopeType.SERVLET)
protected HttpServletRequest servletRequest;
@Action
public void view() {
if (logger.isInfoEnabled())
logger.info("LoginAction.view()");
// Code for getting ip Address
forwardTo("/login.jsp");
}
}
And problem is solved. :-)