Skip to main content



      Home
Home » Eclipse Projects » Equinox » Jetty on OSGi - Servlet concurrency
Jetty on OSGi - Servlet concurrency [message #503373] Sat, 12 December 2009 09:09 Go to next message
Eclipse UserFriend
Hi,

I've sucessfully embedded Jetty as a servlet container. But there is a quite strange behaviour regarding Servlet concurrency. When creating a new Servlet, like this :

public class Servlet extends HttpServlet {
public int i = 0 ;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
resp.getWriter().println("i="+i);
i=i+1;
}
}

it appears that the member variable "i" continues to grow up each time I refresh my web page.
Is it a configuration problem or a correct behaviour ?

Then, do you know where I can find documentation explaining how Jetty inside Equinox handles threads ? It appears each time I'm trying to debugging, I'm still on the same thread . Launching conccurent accesses to the server leads to blocking situations where one page has to wait the end of the previous one to start.

Have you experienced something like this ? Can you please tell me if I missed something ?

Thanks for your help.

Sebastien
Re: Jetty on OSGi - Servlet concurrency [message #504028 is a reply to message #503373] Wed, 16 December 2009 15:53 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

This is just as expected and is simply explained by the fact that each Servlet is only instanced once.
So all HTTP requests joins the same running servlet instance, and this natually makes it hard to have
member variables at all.

//L



"Sebastien JUST" <sebastien@seij.net> skrev i meddelandet news:hg086g$hao$1@build.eclipse.org...
> Hi,
> I've sucessfully embedded Jetty as a servlet container. But there is a quite strange behaviour regarding Servlet concurrency.
> When creating a new Servlet, like this :
> public class Servlet extends HttpServlet {
> public int i = 0 ; @Override
> protected void doGet(HttpServletRequest req, HttpServletResponse resp)
> throws ServletException, IOException {
> resp.getWriter().println("i="+i);
> i=i+1;
> }
> }
>
> it appears that the member variable "i" continues to grow up each time I refresh my web page. Is it a configuration problem or a
> correct behaviour ?
> Then, do you know where I can find documentation explaining how Jetty inside Equinox handles threads ? It appears each time I'm
> trying to debugging, I'm still on the same thread . Launching conccurent accesses to the server leads to blocking situations where
> one page has to wait the end of the previous one to start.
> Have you experienced something like this ? Can you please tell me if I missed something ?
>
> Thanks for your help.
>
> Sebastien
Re: Jetty on OSGi - Servlet concurrency [message #504464 is a reply to message #504028] Sat, 19 December 2009 14:03 Go to previous message
Eclipse UserFriend
Shame on me I didn't noticed this before , my previous container hided the fact.

Thank you !
Previous Topic:Equinox secure store password not retrieved on IDE crash
Next Topic:Unsing p2 director in an RCP application
Goto Forum:
  


Current Time: Wed Jul 23 10:58:59 EDT 2025

Powered by FUDForum. Page generated in 0.04606 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top