Common usage of HttpServletRequest is when getting the request variables or for HttpServletResponse when downloading a file.
How to inject:
REST:
In REST it's as simply as injecting the HttpServlet object. For example:
@Context
private HttpServletResponse httpServletResponse;
@Context
private HttpServletRequest httpServletRequest;
As for SOAP, it's almost the same:
@Resource
protected WebServiceContext webServiceContext;
MessageContext mc = webServiceContext.getMessageContext();
HttpServletResponse response = (HttpServletResponse) mc.get(MessageContext.SERVLET_RESPONSE);
0 nhận xét:
Đăng nhận xét