You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Vidar Ramdal <vi...@idium.no> on 2008/02/15 13:32:17 UTC

Servlet resolution broken?

I'm trying to register a servlet to handle requests with a ".menu" extension:
* @scr.property
 *   name="sling.servlet.extensions"
 *   value="menu"

Then I post some content:
curl -F"sling:resourceType=foo/bar" -F"title=some title"
http://admin:admin@localhost:8888/content/mynode

If I now visit http://localhost:8888/content/mynode, I get the
expected default rendering (StreamRendererServlet).

If I visit http://localhost:8888/content/mynode.menu, I get a "No
default renderer found for extension='menu' (500)" error.

Just to make sure I haven't made a mistake in my servlet, I change the
javadoc annotation to
* @scr.property
 *   name="sling.servlet.resourceTypes"
 *   value="foo/bar"

Visiting http://localhost:8888/content/mynode and even
http://localhost:8888/content/mynode.menu invokes my servlet.

So it seems resolving a servlet from a resource type works, but not
from an extension.
Am I doing something wrong, or is this a bug?

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Servlet resolution broken?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Feb 15, 2008 3:50 PM, Felix Meschberger <fm...@gmail.com> wrote:

> >... Ah, I see. I wanted to make a servlet that would respond to the .menu
> > extension regardless of resourceType, but if that's not possible, I'll
> > work around it. Thanks for your help!
> >
>
> That is possible: just use sling/servlet/default as the resource type
> and you are defining a default servlet for the menu request extension....

Do we have automated tests for the different ways of "wiring" servlets?

If not we should at least create a JIRA issue to make sure we create
such tests, eventually.

-Bertrand

Re: Servlet resolution broken?

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Vidal,

Am Freitag, den 15.02.2008, 15:39 +0100 schrieb Vidar Ramdal:
> On 2/15/08, Felix Meschberger <fm...@gmail.com> wrote:
> > Hi Vidal,
> >
> >  The sling.servlet.resourceTypes annotation is required, otherwise the
> >  servlet is just ignored. That is, in your first example, where you just
> >  define the sling.servlet.extensions, Sling does not know to which
> >  resource type the servlet applies and cannot handle it.
> >
> >   @scr.property name="sling.servlet.extensions" value="menu"
> >   @scr.property name="sling.servlet.resourceTypes" value="foo/bar"
> >
> >
> > This defines the servlet to handle requests for foo/bar resources where
> >  the reqest extension is menu.
> 
> Ah, I see. I wanted to make a servlet that would respond to the .menu
> extension regardless of resourceType, but if that's not possible, I'll
> work around it. Thanks for your help!
> 

That is possible: just use sling/servlet/default as the resource type
and you are defining a default servlet for the menu request extension.

Regards
Felix


Re: Servlet resolution broken?

Posted by Vidar Ramdal <vi...@idium.no>.
On 2/15/08, Felix Meschberger <fm...@gmail.com> wrote:
> Hi Vidal,
>
>  The sling.servlet.resourceTypes annotation is required, otherwise the
>  servlet is just ignored. That is, in your first example, where you just
>  define the sling.servlet.extensions, Sling does not know to which
>  resource type the servlet applies and cannot handle it.
>
>   @scr.property name="sling.servlet.extensions" value="menu"
>   @scr.property name="sling.servlet.resourceTypes" value="foo/bar"
>
>
> This defines the servlet to handle requests for foo/bar resources where
>  the reqest extension is menu.

Ah, I see. I wanted to make a servlet that would respond to the .menu
extension regardless of resourceType, but if that's not possible, I'll
work around it. Thanks for your help!

-- 
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Akersgata 16, N-0158 Oslo, Norway

Re: Servlet resolution broken?

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Vidal,

The sling.servlet.resourceTypes annotation is required, otherwise the
servlet is just ignored. That is, in your first example, where you just
define the sling.servlet.extensions, Sling does not know to which
resource type the servlet applies and cannot handle it.

  @scr.property name="sling.servlet.extensions" value="menu"
  @scr.property name="sling.servlet.resourceTypes" value="foo/bar"

This defines the servlet to handle requests for foo/bar resources where
the reqest extension is menu.

Hope this helps.

Regards
Felix


Am Freitag, den 15.02.2008, 13:32 +0100 schrieb Vidar Ramdal:
> I'm trying to register a servlet to handle requests with a ".menu" extension:
> * @scr.property
>  *   name="sling.servlet.extensions"
>  *   value="menu"
> 
> Then I post some content:
> curl -F"sling:resourceType=foo/bar" -F"title=some title"
> http://admin:admin@localhost:8888/content/mynode
> 
> If I now visit http://localhost:8888/content/mynode, I get the
> expected default rendering (StreamRendererServlet).
> 
> If I visit http://localhost:8888/content/mynode.menu, I get a "No
> default renderer found for extension='menu' (500)" error.
> 
> Just to make sure I haven't made a mistake in my servlet, I change the
> javadoc annotation to
> * @scr.property
>  *   name="sling.servlet.resourceTypes"
>  *   value="foo/bar"
> 
> Visiting http://localhost:8888/content/mynode and even
> http://localhost:8888/content/mynode.menu invokes my servlet.
> 
> So it seems resolving a servlet from a resource type works, but not
> from an extension.
> Am I doing something wrong, or is this a bug?
>