[prev in list] [next in list] [prev in thread] [next in thread] 

List:       wink-user
Subject:    Re: ServletContext
From:       "Rekasius, Rimas V" <rimas_rekasius () baxter ! com>
Date:       2014-01-30 16:00:55
Message-ID: CF0FD18E.4AEB%rimas_rekasius () baxter ! com
[Download RAW message or body]

--_000_CF0FD18E4AEBrimasrekasiusbaxtercom_
MIME-Version: 1.0
Content-Type: text/plain; charset="windows-1252"
Content-Transfer-Encoding: quoted-printable

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 <steve.pruitt@hp.com<mailto:steve.pruitt@hp.com>>
Reply-To: "user@wink.apache.org<mailto:user@wink.apache.org>" \
                <user@wink.apache.org<mailto:user@wink.apache.org>>
Date: Thursday, January 30, 2014 at 8:55 AM
To: "user@wink.apache.org<mailto:user@wink.apache.org>" \
                <user@wink.apache.org<mailto:user@wink.apache.org>>
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

--_000_CF0FD18E4AEBrimasrekasiusbaxtercom_
Content-ID: <24747D34A81B7841B00F357447F08A77@mgd.baxter.com>
MIME-Version: 1.0
Content-Type: text/html; charset="windows-1252"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: \
after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, \
sans-serif;"> <div>
<div>Steve,</div>
<div><br>
</div>
<div>Here is a code snippet from a filter that works for us:</div>
<div><br>
</div>
<div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>@Override</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>public void \
doFilter(ServletRequest arg0, ServletResponse arg1,</div> <div><span \
class="Apple-tab-span" style="white-space:pre"></span>FilterChain arg2) throws \
IOException, ServletException {</div> <div><span class="Apple-tab-span" \
style="white-space: pre;"></span>HttpServletRequest request = \
(HttpServletRequest)arg0;</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getContextPath()=&quot; \
&#43; request.getContextPath());</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getLocalAddr()=&quot; \
&#43; request.getLocalAddr());</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getLocalName()=&quot; \
&#43; request.getLocalName());</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getPathInfo()=&quot; \
&#43; request.getPathInfo());</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getPathTranslated()=&quot; \
&#43; request.getPathTranslated());</div> <div><span class="Apple-tab-span" \
style="white-space:pre"></span>System.out.println(&quot;request.getServletPath()=&quot; \
&#43; request.getServletPath());</div> </div>
<div><br>
</div>
<div>Oh, sorry, I just realized you are talking about a WS-RS client, not \
server/service.</div> <div><br>
</div>
<div>
<p class="MsoNormal">Rimas Rekasius</p>
</div>
</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; \
BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; \
PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: \
medium none; PADDING-TOP: 3pt"> <span style="font-weight:bold">From: \
</span>&lt;Pruitt&gt;, Byron S &lt;<a \
href="mailto:steve.pruitt@hp.com">steve.pruitt@hp.com</a>&gt;<br> <span \
style="font-weight:bold">Reply-To: </span>&quot;<a \
href="mailto:user@wink.apache.org">user@wink.apache.org</a>&quot; &lt;<a \
href="mailto:user@wink.apache.org">user@wink.apache.org</a>&gt;<br> <span \
style="font-weight:bold">Date: </span>Thursday, January 30, 2014 at 8:55 AM<br> <span \
style="font-weight:bold">To: </span>&quot;<a \
href="mailto:user@wink.apache.org">user@wink.apache.org</a>&quot; &lt;<a \
href="mailto:user@wink.apache.org">user@wink.apache.org</a>&gt;<br> <span \
style="font-weight:bold">Subject: </span>ServletContext<br> </div>
<div><br>
</div>
<div xmlns:v="urn:schemas-microsoft-com:vml" \
xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" \
xmlns="http://www.w3.org/TR/REC-html40"> <meta name="Generator" content="Microsoft \
Word 14 (filtered medium)"> <style><!--
/* Font Definitions */
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:purple;
	text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
	{mso-style-priority:99;
	mso-style-link:"Balloon Text Char";
	margin:0in;
	margin-bottom:.0001pt;
	font-size:8.0pt;
	font-family:"Tahoma","sans-serif";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri","sans-serif";
	color:windowtext;}
span.BalloonTextChar
	{mso-style-name:"Balloon Text Char";
	mso-style-priority:99;
	mso-style-link:"Balloon Text";
	font-family:"Tahoma","sans-serif";}
.MsoChpDefault
	{mso-style-type:export-only;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">I need a means to determine the real path from my WS-RS \
client.&nbsp; I use Wink as my framework.&nbsp; I have done this is in a regular \
HTTPServlet using the ServletContext getRealPath method.&nbsp; But, I can’t find a \
way to do within my WS-RS class..&nbsp;  I found one example for using the Resource \
annotation, but that does not seem to work.&nbsp; When I run the context member is \
null.<o:p></o:p></p> <p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">My code looks like:<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal" style="text-autospace:none"><span \
style="color:#646464">@Resource</span><o:p></o:p></p> <p class="MsoNormal"><b><span \
style="color:#7F0055">private</span></b><span style="color:black"> WebServiceContext \
</span><span style="color:#0000C0">context</span><span \
style="color:black">;<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:black">:<o:p></o:p></span></p> <p class="MsoNormal" \
style="text-autospace:none"><span style="color:black">ServletContext servletContext = \
(ServletContext) </span><span style="color:#0000C0">context</span><span \
style="color:black">.getMessageContext().get(<u>MessageContext</u>.</span><i><span \
style="color:#0000C0">SERVLET_CONTEXT</span></i><span \
style="color:black">);</span><o:p></o:p></p> <p class="MsoNormal"><span \
style="color:black">String <span style="background:yellow;mso-highlight:yellow"> \
libPath</span> = servletContext.getRealPath(</span><span \
style="color:#2A00FF">&quot;/WEB-INF&quot;</span><span \
style="color:black">);<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="color:black">But context appears to be null.<o:p></o:p></span></p> <p \
class="MsoNormal"><span style="color:black"><o:p>&nbsp;</o:p></span></p> <p \
class="MsoNormal"><span style="color:black">If anyone has alternative method, or \
knows what is wrong the above, any suggestion would be \
appreciated.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="color:black">Thanks.<o:p></o:p></span></p> <p class="MsoNormal"><span \
style="color:black"><o:p>&nbsp;</o:p></span></p> <p class="MsoNormal"><span \
style="color:black">-Steve</span><o:p></o:p></p> </div>
</div>
</div>
</span>
<p>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.</p>

<p>For Translation:</p>

<p>http://www.baxter.com/email_disclaimer</p></body>
</html>

--_000_CF0FD18E4AEBrimasrekasiusbaxtercom_--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic