Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Webapps in Equinox
Webapps in Equinox [message #75695] Thu, 26 October 2006 13:30 Go to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hi,

I installed the bundle org.eclipse.equinox.http.jetty and all its
required bundles.
If I install a webapp bundle, it must use the
org.eclipse.equinox.http.registry's extension point to define where
resources or servlets can be found.

But why does the jetty bundle knows that a new webapp is installed and
how did it get the informations about that webapp?

How can I define the jsp's location in a webapp? Is that feature already
supported?

Thanks for help!!!

Best regards,
Sabine
Re: Webapps in Equinox [message #75713 is a reply to message #75695] Thu, 26 October 2006 13:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ridcully560.yahoo.com

Hello Sabine,

> But why does the jetty bundle knows that a new webapp is installed and
> how did it get the informations about that webapp?

sorry, can't help you with that one.

> How can I define the jsp's location in a webapp? Is that feature already
> supported?

I do it as follows:

> HttpContext commonContext = service.createDefaultHttpContext();
>
> Servlet adaptedJspServlet = new org.eclipse.equinox.jsp.jasper.ContextPathServletAdaptor(new org.eclipse.equinox.jsp.jasper.JspServlet(context.getBundle( ), "/WebContent"), "/jsp", "/WebContent");
>
> service.registerServlet("/jsp" + "/*.jsp", adaptedJspServlet, null, commonContext);

Where "/WebContent" is the top-directory where all my web-recources are
located. Actually I've got another directory called "jsp" inside that
one, but it seems that all subdirectories are scanned for JSPs.

And "/jsp" is the name under which the JSPs are available. So for example:

<YourProject>/WebContent/Main.jsp
->
http://localhost/jsp/Main.jsp

and

<YourProject>/WebContent/jsp-files/Main.jsp
->
http://localhost/jsp/jsp-files/Main.jsp

On http://www.eclipse.org/equinox/server/jsp_support.php you can
download and import a team project set. I think you need that one to get
the bundles that support JSPs.

Near the end of that page there's also a project for JSTL-support.

Hope that helps,
Johannes
Re: Webapps in Equinox [message #75729 is a reply to message #75713] Fri, 27 October 2006 08:46 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

Hello Johannes,

thanks for help!
But I have a question:
Where does the "HttpContext" and "service" came from?

Best regards,
Sabine

Johannes schrieb:
> Hello Sabine,
>
>> But why does the jetty bundle knows that a new webapp is installed and
>> how did it get the informations about that webapp?
>
>
> sorry, can't help you with that one.
>
>> How can I define the jsp's location in a webapp? Is that feature
>> already supported?
>
>
> I do it as follows:
>
>> HttpContext commonContext = service.createDefaultHttpContext();
>>
>> Servlet adaptedJspServlet = new
>> org.eclipse.equinox.jsp.jasper.ContextPathServletAdaptor(new
>> org.eclipse.equinox.jsp.jasper.JspServlet(context.getBundle( ),
>> "/WebContent"), "/jsp", "/WebContent");
>>
>> service.registerServlet("/jsp" + "/*.jsp", adaptedJspServlet, null,
>> commonContext);
>
>
> Where "/WebContent" is the top-directory where all my web-recources are
> located. Actually I've got another directory called "jsp" inside that
> one, but it seems that all subdirectories are scanned for JSPs.
>
> And "/jsp" is the name under which the JSPs are available. So for example:
>
> <YourProject>/WebContent/Main.jsp
> ->
> http://localhost/jsp/Main.jsp
>
> and
>
> <YourProject>/WebContent/jsp-files/Main.jsp
> ->
> http://localhost/jsp/jsp-files/Main.jsp
>
> On http://www.eclipse.org/equinox/server/jsp_support.php you can
> download and import a team project set. I think you need that one to get
> the bundles that support JSPs.
>
> Near the end of that page there's also a project for JSTL-support.
>
> Hope that helps,
> Johannes
Re: Webapps in Equinox [message #75746 is a reply to message #75729] Fri, 27 October 2006 09:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ridcully560.yahoo.com

Hello Sabine,

> thanks for help!
> But I have a question:
> Where does the "HttpContext" and "service" came from?

I think I forgot something. I wrote a class extending ServiceTracker
(Following a tutorial from the EclipseCon(?), I think - but I don't have
that one here anymore. I'll post where it can be found when I get it again).

> import javax.servlet.Servlet;
>
> import org.osgi.framework.BundleContext;
> import org.osgi.framework.ServiceReference;
> import org.osgi.service.http.HttpContext;
> import org.osgi.service.http.HttpService;
> import org.osgi.util.tracker.ServiceTracker;
>
> public class MainPluginTracker extends ServiceTracker {
>
> private String dir;
> private String alias;
>
> public MainPluginTracker(BundleContext context, String alias, String dir) {
> super(context, HttpService.class.getName(), null);
> this.dir = dir;
> this.alias = alias;
> }
>
> public Object addingService(ServiceReference reference) {
> final HttpService service = (HttpService) context.getService(reference);
> try {
> HttpContext commonContext = service.createDefaultHttpContext();
>
> Servlet adaptedJspServlet = new org.eclipse.equinox.jsp.jasper.ContextPathServletAdaptor(new org.eclipse.equinox.jsp.jasper.JspServlet(context.getBundle( ), dir), alias, dir);
> service.registerServlet(alias + "/*.jsp", adaptedJspServlet, null, commonContext);
> } catch (Exception e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> return service;
> }
> }

And I use that class in the BundleActivator start()-Method:

> httpServiceTracker = new MainPluginTracker(context, "/jsp", "/WebContent");
> httpServiceTracker.open();

As you can see, I added the two variables "alias" and "dir", to use that
Tracker with different plugins.

Hope it is a bit clearer now. Sorry, I thought you could use the code I
posted yersterday in the Activator, but that don't seem to work.

Johannes
Re: Webapps in Equinox [message #78335 is a reply to message #75695] Sun, 03 December 2006 04:34 Go to previous message
Eclipse UserFriend
Originally posted by: skaegi.sympatico.ca

Hi Sabine,

comments inlined.

> If I install a webapp bundle, it must use the
> org.eclipse.equinox.http.registry's extension point to define where
> resources or servlets can be found.
>
> But why does the jetty bundle knows that a new webapp is installed and
> how did it get the informations about that webapp?

1) org.eclipse.equinox.http.jetty exposes an OSGi Http Service.
2) org.eclipse.equinox.http.registry uses the extension registry to listens
for servlet and resource extensions and then will handle the registering in
all available Http Service instances.

> How can I define the jsp's location in a webapp? Is that feature already
> supported?
JSPs (and taglibs) are found through the ServletContext.getResource methods
so it's a matter of setting up your resource paths correctly. The OSGi Http
Service creates a ServletContext from the getResource methods in the
HttpContext. In addition to servlets and resources there is another
extension point in org.eclipse.equinox.http.registry which specifically
deals with setting up an httpcontext which you might look at.

You can take a look at JSP support here
http://www.eclipse.org/equinox/server/jsp_support.php
There is no direct integration of this support in http.registry currently
however it's a planned item and will be added shortly.

-Simon
>
> Thanks for help!!!
>
> Best regards,
> Sabine
>
Previous Topic:Debugging/Testing Plugins, where is the dynmaic behaviour??
Next Topic:Performance metrics and commercial deployment info required
Goto Forum:
  


Current Time: Tue Sep 24 05:30:59 GMT 2024

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

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

Back to the top