[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] general embedded jetty questions
|
You can take a look at my Mongodb rest server as example, which is
Jetty embedded
https://sites.google.com/site/mongodbjavarestserver/home
On Wed, May 23, 2012 at 10:30 AM, S Ahmed <sahmed1020@xxxxxxxxx> wrote:
> Hoping someone could help me on this, this is a web service endpoint and I
> have to support the servlet being fired by 2 different url structures (if
> possible), so like:
>
> /my_api/first/path
>
> /some/other/path
>
> I have this currently:
>
> Server server = new Server(8090);
>
> ServletContextHandler servletContextHandler = new
> ServletContextHandler();
> servletContextHandler.setContextPath("/my_api");
> servletContextHandler.addServlet(new ServletHolder(new MyServlet()),
> "/first/path");
>
> server.setHandler(servletContextHandler);
>
> logger.info("starting jetty");
> server.start();
> server.join();
>
>
> On Mon, Apr 23, 2012 at 1:01 PM, S Ahmed <sahmed1020@xxxxxxxxx> wrote:
>>
>> any help on getting the servelt to respond using a different path?
>>
>>
>> On Sun, Apr 22, 2012 at 1:10 PM, S Ahmed <sahmed1020@xxxxxxxxx> wrote:
>>>
>>> How can I map the same servlet to 2 different urls?
>>>
>>> I have this so far:
>>>
>>> Server server = new Server(8090);
>>>
>>> ServletContextHandler servletContextHandler = new
>>> ServletContextHandler();
>>> servletContextHandler.setContextPath("/my_api");
>>> servletContextHandler.addServlet(new ServletHolder(new
>>> MyServlet()), "/first/path");
>>>
>>> server.setHandler(servletContextHandler);
>>>
>>> logger.info("starting jetty");
>>> server.start();
>>> server.join();
>>>
>>>
>>> Can I map it to another url also?
>>>
>>> Also, what is the default pool size and pool type? is it quedthreadpool?
>>>
>>> On Tue, Apr 17, 2012 at 2:57 AM, Thomas Becker <tbecker@xxxxxxxxxxx>
>>> wrote:
>>>>
>>>> Hi S Ahmed,
>>>>
>>>> in your case a Servlet is the better fit. Instead using a handler write
>>>> a servlet and only override the doPost() method if you only want to reply to
>>>> POST requests. Use the servlet tutorials provided by Oracle or any other of
>>>> the million tutorials in the web on how to do so.
>>>>
>>>> How to run servlets embedded is described in the jetty wiki @ eclipse:
>>>> http://wiki.eclipse.org/Jetty/Tutorial/Embedding_Jetty
>>>>
>>>> Have fun,
>>>> Thomas
>>>>
>>>>
>>>> On 4/16/12 11:12 PM, S Ahmed wrote:
>>>>
>>>> My embedded jetty 'main' looks like:
>>>>
>>>> Server server = new Server(8090);
>>>>
>>>>
>>>> ContextHandler contextHandler = new ContextHandler();
>>>> contextHandler.setContextPath("/some/path");
>>>> contextHandler.setResourceBase(".");
>>>>
>>>> contextHandler.setClassLoader(Thread.currentThread().getContextClassLoader());
>>>>
>>>>
>>>> server.setHandler(contextHandler);
>>>> server.setHandler(new SomeHandler(someService));
>>>>
>>>> server.start();
>>>> server.join();
>>>>
>>>> 1. I created the context handler so I could create a context path so
>>>> people will go to /some/path and then SomeHandler will response. (but the
>>>> problem is going to just / also fires the SomeHandler....)
>>>> Can I add this contextPath to SomeHandler somehow? My SomeHandler
>>>> looks like:
>>>>
>>>> public class SomeHandler extends AbstractHandler
>>>>
>>>> 2. Can I have SomeHandler ONLY response to POST requests?
>>>>
>>>> 3. Not sure what the default thread pool settings are if I don't
>>>> explicitly set it? Is queued thread pool the suggested pool to use?
>>>>
>>>>
>>>> _______________________________________________
>>>> jetty-users mailing list
>>>> jetty-users@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/jetty-users
>>>>
>>>>
>>>> --
>>>> thomas becker
>>>> tbecker@xxxxxxxxxxx
>>>>
>>>> http://webtide.com / http://intalio.com
>>>> (the folks behind jetty and cometd)
>>>
>>>
>>
>
>
> _______________________________________________
> jetty-users mailing list
> jetty-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>