Steve,
Here is a code snippet from a filter that works for us:
@Override
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest)arg0;
System.out.println("request.getContextPath()=" + request.getContextPath());
System.out.println("request.getLocalAddr()=" + request.getLocalAddr());
System.out.println("request.getLocalName()=" + request.getLocalName());
System.out.println("request.getPathInfo()=" + request.getPathInfo());
System.out.println("request.getPathTranslated()=" +
request.getPathTranslated());
System.out.println("request.getServletPath()=" + request.getServletPath());
Oh, sorry, I just realized you are talking about a WS-RS client, not
server/service.
Rimas Rekasius
From: <Pruitt>, Byron S <[email protected]<mailto:[email protected]>>
Reply-To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Date: Thursday, January 30, 2014 at 8:55 AM
To: "[email protected]<mailto:[email protected]>"
<[email protected]<mailto:[email protected]>>
Subject: ServletContext
I need a means to determine the real path from my WS-RS client. I use Wink as
my framework. I have done this is in a regular HTTPServlet using the
ServletContext getRealPath method. But, I can’t find a way to do within my
WS-RS class.. I found one example for using the Resource annotation, but that
does not seem to work. When I run the context member is null.
My code looks like:
@Resource
private WebServiceContext context;
:
ServletContext servletContext = (ServletContext)
context.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
String libPath = servletContext.getRealPath("/WEB-INF");
But context appears to be null.
If anyone has alternative method, or knows what is wrong the above, any
suggestion would be appreciated.
Thanks.
-Steve
The information transmitted is intended only for the person(s) or entity to
which it is addressed and may contain confidential and/or legally privileged
material. Delivery of this message to any person other than the intended
recipient(s) is not intended in any way to waive privilege or confidentiality.
Any review, retransmission, dissemination or other use of, or taking of any
action in reliance upon, this information by entities other than the intended
recipient is prohibited. If you receive this in error, please contact the
sender and delete the material from any computer.
For Translation:
http://www.baxter.com/email_disclaimer