Thanks Tim,

That’s exactly what I thought but without it I get the following from Jetty.
HTTP ERROR 404
Problem accessing /myApp/. Reason:
    Not Found

Perhaps that’s related to something else and the presence/absence of 
Web-ContextPath is triggering the other issue.  I’ll see what I can figure out 
in that regard.

I do have one last question though. I’m wondering what the syntax is to 
associate multiple URL patterns with a single servlet.  I assume I can use 
wildcarding and stuff like that but can I use a Java RE?  How about a URL list? 
 Comma separated, bounded by braces, brackets?

I’m thought I had a copy of the R6 compendium squirreled away so that I could 
just look it up but it may be on my machine at home and for some reason I’m not 
seeing it at osgi.org even though I’m sure it’s there somewhere.

Scott

From: Tim Ward <[email protected]>
Sent: Tuesday, October 23, 2018 10:09 AM
To: [email protected]
Subject: Re: Http Whiteboard

I wouldn’t expect you to need anything specific in your bnd file. 
Web-ContextPath is part of a different OSGi specification (the Web Application 
Bundle spec) so there shouldn’t be any need for that at all.

Best Regards,

Tim


On 23 Oct 2018, at 17:06, Leschke, Scott 
<[email protected]<mailto:[email protected]>> wrote:

Thanks Tim.  That was the problem. I noticed that just after I sent the email 
but hadn’t had a chance to try it yet.  I pulled that from a YouTube video Ray 
Auge did way back in 2014 and sort of blindly regurgitated what I saw.

There’s something else I noticed though.  It would seem that it’s still 
necessary to define
Web-ContextPath .bnd file as it doesn’t appear to work without that.  Is that 
right?

From: Tim Ward <[email protected]<mailto:[email protected]>>
Sent: Monday, October 22, 2018 4:28 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: Http Whiteboard

I’m pretty sure that your ServletContextHelper isn’t advertised as a service 
and is therefore invisible to the whiteboard. ServletContextHelper is not an 
interface so you need to be explicit.

Tim
Sent from my iPhone

On 22 Oct 2018, at 23:04, Leschke, Scott 
<[email protected]<mailto:[email protected]>> wrote:

I’ve in the process of trying to convert a couple of servlets over to user 
HttpWhiteboard. I looked online for an example and it seemed pretty straight 
forward.
Based on my understanding, I came up with the following but it doesn’t work. 
Jetty doesn’t have a myApp context. I assume there is something missing?

Help?

Scott


@Component(
       property  = {
              HTTP_WHITEBOARD_CONTEXT_NAME + '=' + ContextHelper.CTX_NAME,
              HTTP_WHITEBOARD_CONTEXT_PATH + '=' + ContextHelper.CTX_PATH
       }
)
public class ContextHelper
       extends org.osgi.service.http.context.ServletContextHelper
{
       public static final String CTX_NAME = "myApp";
       public static final String CTX_PATH = '/' + CTX_NAME;
}


@Component(
       name      = “myApp.listings",
       property  = {
              HTTP_WHITEBOARD_CONTEXT_SELECT  + "=(" + 
HTTP_WHITEBOARD_CONTEXT_NAME + '=' + ContextHelper.CTX_NAME + ')',
              HTTP_WHITEBOARD_SERVLET_NAME    + '=' + "MyApp Listings",
              HTTP_WHITEBOARD_SERVLET_PATTERN + '=' + "/list/*"
       },
       service   = Servlet.class,
       immediate = true)
@Designate(
       ocd = AppConfig.class)
public class Listings
       implements HttpServlet
{…}

Reply via email to