How To Access Httpservletrequest In Addition To Httpservletresponse Inward Both Residuum In Addition To Lather Service

There are times when nosotros involve either HttpServletRequest or HttpServletResponse inwards our REST or SOAP api. These objects are readily available if y'all know how to inject them.

Common exercise of HttpServletRequest is when getting the asking variables or for HttpServletResponse when downloading a file.

How to inject:
REST:

In REST it's every bit exactly every bit injecting the HttpServlet object. For example:

@Context  mortal HttpServletResponse httpServletResponse;  @Context  mortal HttpServletRequest httpServletRequest; 


As for SOAP, it's nearly the same:
 @Resource protected WebServiceContext webServiceContext;  MessageContext mc = webServiceContext.getMessageContext(); HttpServletResponse reply = (HttpServletResponse) mc.get(MessageContext.SERVLET_RESPONSE); 
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.