1 2HttpServletRequest request = ServletActionContext.getRequest(); if (request != null) { // do something here }
You should always assume that ServletActionContext.getRequest() will return null. ServletActionContext is only populated if the request comes in through Struts. There are a number of circumstances in which it will not be populated, either because a web request has come in through some other path, or because there was no web request in the first place:
Treat ServletActionContext
as a bonus. If it's populated you can do neat things with it, but don't rely on it.
Rate this page: