So If I have a content page, say /content/mysite/accounts.html. And I
want to handle GET request for this, there are following options.

1. If I have a template/component backing accounts.html, which is JSP,
I can call a service in JSP scriptlet
So, the sequence is

GET /content/mysite/accounts.html

accounts.html ==> accounts.jsp (component)

account.jsp ==> <%  AccountService service =
sling.getService(AccountService.class) %>

Display account details.

2. If I do not want GET request to directly go to JSP,  I will write a
servlet for handling GET request under path say /mysite/accounts

GET /mysite/accounts/

SlingServlet for handling
Populate account object in session
forward request to /content/mysite/accounts.html

3. Instead of servlet, write a ResourceProvider for path /mysite/accounts

GET /mysite/accounts

ResourceProvider builds AccountSummary resource

How does this wire back to JSP component??


Which of the above options is generally used? I want to avoid option 1.

Thanks,
Unmesh

On Mon, Feb 14, 2011 at 4:55 AM, Justin Edelson
<[email protected]> wrote:
> ResourceProviders and Servlets do completely different things. 
> ResourceProviders provide resources. Servlets produce representations of 
> resources.
>
> Justin
>
> On Feb 13, 2011, at 4:23 PM, Unmesh Joshi <[email protected]> wrote:
>
>> Hi,
>>
>> In Sling, we can Servlets are written for handling POST request. (Even
>> JSPs and other scripts can be used, but I will like to stick to
>> Servlets)
>> For GET requests, either Servlets or ResourceProviders can be used.
>> What is the common idiom or good design practice? ResourceProviders or
>> Servlets?
>>
>> Thanks,
>> Unmesh
>

Reply via email to