Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Registering JspServlet via ext. point
Registering JspServlet via ext. point [message #106396] Mon, 17 March 2008 08:04 Go to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi all,

In order to have jsp support I have register JspServlet programmatically :

final HttpService httpService = (HttpService)context.getService(reference);
HttpContext httpContext = new
BundleEntryHttpContext(context.getBundle(),"/web");
httpService.registerServlet("/*.jsp",new JspServlet(context.getBundle(),
"/web"), null, httpContext);

So far, so good.

However, to be able to exchange data with RAP I have to use RAP
HttpContext with id 'org.eclipse.rap.httpcontext' declaratively via ext.
point mechanism.

Question:

1. Since I can not register JspServlet via ext. point how can I refer to
RAP HttpContext ?
2. Or, how can I refer to RAP HttpContext programmatically & replacing
above BundleEntryHttpContext ?

Any help would be greatly appreciated.

Best Regards,

Setya
Re: Registering JspServlet via ext. point [message #106425 is a reply to message #106396] Mon, 17 March 2008 11:36 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Setya schrieb:
> 1. Since I can not register JspServlet via ext. point how can I refer to
> RAP HttpContext ?

You can do it using org.eclipse.equinox.jsp.jasper.registry.JSPFactory
which is an IExecutableExtensionFactory. See its JavaDoc for details.

<extension
point="org.eclipse.equinox.http.registry.servlets">
<servlet
alias="/ext/*.jsp"
class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory">
</servlet>
</extension>

> 2. Or, how can I refer to RAP HttpContext programmatically & replacing
> above BundleEntryHttpContext ?

Have a look at:
org.eclipse.equinox.http.registry.HttpContextExtensionServic e

:)

-Gunnar


--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Registering JspServlet via ext. point [message #106439 is a reply to message #106425] Mon, 17 March 2008 13:35 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Just what I needed.

Thanks and Regards,

Setya
Re: Registering JspServlet via ext. point [message #106480 is a reply to message #106439] Tue, 18 March 2008 05:00 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

I've tried your suggestion by registering JSPFactory via ext. point:

<extension id="com.farbeyond.core.servlets"
point="org.eclipse.equinox.http.registry.servlets">
<servlet alias="/*.jsp"
class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory"/ >
</extension>

But the browser keeps showing the jsp code instead.

Also the JSPFactory Javadoc says that we register the alias by appending
the path to class definition using ':' as separator or by using xml
parameters.

Am I missing something here ?


Best Regards,

Setya
Re: Registering JspServlet via ext. point [message #106489 is a reply to message #106480] Tue, 18 March 2008 13:30 Go to previous messageGo to next message
Gunnar Wagenknecht is currently offline Gunnar WagenknechtFriend
Messages: 486
Registered: July 2009
Location: San Francisco ✈ Germany
Senior Member

Setya schrieb:
> Also the JSPFactory Javadoc says that we register the alias by appending
> the path to class definition using ':' as separator or by using xml
> parameters.

You only need to specify a folder (using the ':' separator) if the JSPs
are not located in the bundle root but in a folder below.

Can you check if all bundles are resolved properly?

For reference, here is the link to the sample the demonstrate it's usage.
http://sse-examples.cvs.sourceforge.net/sse-examples/sample. jsp.registry/

-Gunnar

--
Gunnar Wagenknecht
gunnar@wagenknecht.org
http://wagenknecht.org/
Re: Registering JspServlet via ext. point [message #106515 is a reply to message #106489] Wed, 19 March 2008 04:06 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Gunnar,

> You only need to specify a folder (using the ':' separator) if the JSPs
> are not located in the bundle root but in a folder below.

I've tried the following with no luck:

<servlet
class=" org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/web/*.js p "/>

My jsp's reside under /web folder.

> Can you check if all bundles are resolved properly?

Yes, here's the result of ss command:

Configuration location:

file:/home/setya/Projects/Farbeyond/workspace-rap/.metadata/ .plugins/org.eclipse.pde.core/FBCore-OSGI/
Configuration file:

file:/home/setya/Projects/Farbeyond/workspace-rap/.metadata/ .plugins/org.eclipse.pde.core/FBCore-OSGI/config.ini
loaded
Install location:
file:/home/setya/Installers/Eclipse/EclipseRAP/eclipse-rap-1 .1.0-M2/
Framework located:

file:/home/setya/Installers/Eclipse/EclipseRAP/eclipse-rap-1 .1.0-M2/plugins/org.eclipse.osgi_3.3.1.R33x_v20070828.jar
Framework classpath:

file:/home/setya/Installers/Eclipse/EclipseRAP/eclipse-rap-1 .1.0-M2/plugins/org.eclipse.osgi_3.3.1.R33x_v20070828.jar
Debug options:
file:/home/setya/.options not found

osgi> Time to load bundles: 247
Mar 19, 2008 10:50:10 AM org.mortbay.http.HttpServer doStart
INFO: Version Jetty/5.1.x
Mar 19, 2008 10:50:11 AM org.mortbay.util.Container start
INFO: Started org.mortbay.jetty.servlet.ServletHandler@1ce784b
Mar 19, 2008 10:50:11 AM org.mortbay.util.Container start
INFO: Started HttpContext[/,/]
Mar 19, 2008 10:50:11 AM org.mortbay.http.SocketListener start
INFO: Started SocketListener on 0.0.0.0:8080
Mar 19, 2008 10:50:11 AM org.mortbay.util.Container start
INFO: Started org.mortbay.http.HttpServer@fbb7cb
ss

Framework is launched.

id State Bundle
0 ACTIVE org.eclipse.osgi_3.3.1.R33x_v20070828
1 ACTIVE org.eclipse.rap.ui_1.1.0.20080220-1610
2 ACTIVE org.eclipse.rap.ui.workbench_1.1.0.20080220-1610
3 ACTIVE org.eclipse.equinox.http.registry_1.0.100.v20071203
4 ACTIVE org.apache.commons.el_1.0.0.v200706111724
5 ACTIVE org.apache.jasper_5.5.17.v200706111724
6 ACTIVE com.farbeyond.core_1.0.0
7 ACTIVE org.eclipse.core.runtime_3.3.100.v20070530
8 ACTIVE org.eclipse.core.commands_3.3.0.I20070605-0010
9 ACTIVE org.eclipse.rap.rwt_1.1.0.20080220-1610
10 ACTIVE org.eclipse.equinox.http.jetty_1.0.100.v20080201
11 ACTIVE org.eclipse.equinox.jsp.jasper.registry_1.0.0.v20070607
12 ACTIVE org.eclipse.rap.jface_1.1.0.20080220-1610
13 ACTIVE org.apache.commons.logging_1.0.4.v200711021015
14 ACTIVE org.eclipse.equinox.http.helper_1.0.0.qualifier
15 ACTIVE org.mortbay.jetty_5.1.11.v200711021015
16 ACTIVE org.eclipse.rap.ui.views_1.1.0.20080220-1610
17 ACTIVE javax.servlet.jsp_2.0.0.v200706191603
18 ACTIVE org.eclipse.equinox.common_3.3.0.v20070426
19 ACTIVE org.eclipse.osgi.services_3.1.200.v20070605
20 ACTIVE org.eclipse.equinox.registry_3.3.1.R33x_v20070802
21 ACTIVE org.eclipse.equinox.preferences_3.2.100.v20070522
22 ACTIVE org.eclipse.core.jobs_3.3.1.R33x_v20070709
23 ACTIVE org.eclipse.equinox.jsp.jasper_1.0.1.R33x_v20070816
24 ACTIVE org.eclipse.core.contenttype_3.2.100.v20070319
25 ACTIVE javax.servlet_2.4.0.v200711021030
26 ACTIVE org.eclipse.equinox.http.servlet_1.0.100.v20080201
27 ACTIVE org.eclipse.rap.ui.forms_1.1.0.20080220-1610
28 ACTIVE org.eclipse.core.expressions_3.3.0.v20070606-0010
29 ACTIVE org.eclipse.equinox.app_1.0.1.R33x_v20070828

osgi>

Here's part of my plugin.xml :

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<plugin>

...

<extension id="com.farbeyond.core.resources"
point="org.eclipse.equinox.http.registry.resources">
<resource alias="/web" base-name="/web"/>
<resource alias="/images" base-name="/web/images"/>
<resource alias="/css" base-name="/web/css"/>
<resource alias="/js" base-name="/web/js"/>
</extension>

<extension id="com.farbeyond.core.servlets"
point="org.eclipse.equinox.http.registry.servlets">
<servlet alias="/welcome"
class="com.farbeyond.core.servlets.WelcomeServlet"/>
<servlet alias="/login"
class="com.farbeyond.core.servlets.LoginServlet"/>
<servlet alias="/main" class="com.farbeyond.core.servlets.MainServlet"/>
<servlet alias="/*.jsp"
class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory"/ >
</extension>
</plugin>


Here's my MANIFEST.MF :

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %core.plugin.name
Bundle-SymbolicName: com.farbeyond.core;singleton:=true
Bundle-Version: 1.0.0
Bundle-Vendor: %main.title
Bundle-Localization: plugin
Require-Bundle: org.eclipse.rap.ui,
org.eclipse.rap.ui.forms,
org.eclipse.equinox.http.registry,
javax.servlet,
org.eclipse.osgi.services,
org.eclipse.equinox.jsp.jasper,
org.eclipse.equinox.http.helper,
org.eclipse.equinox.jsp.jasper.registry
Bundle-Activator: com.farbeyond.core.ui.CorePlugin
Eclipse-LazyStart: true
Bundle-ClassPath: bin/,.
Export-Package: com.farbeyond.core.extpoint

Just for checking I've deliberately change the JSPFactory servlet class
into the wrong class, but the app just runs without problems and all
bundles are marked as ACTIVE. Where can I find the log files ?

Regards,

Setya
Re: Registering JspServlet via ext. point [message #106529 is a reply to message #106515] Wed, 19 March 2008 07:04 Go to previous messageGo to next message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Hi,

After digging the source code for quite sometime, I've got it working by
changing the ext. point registration into:

<servlet alias="/*.jsp"
class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/web "/>

And I can acess the page using url :

http://localhost:8080/main.jsp

Best Regards,

Setya
Re: Registering JspServlet via ext. point [message #106571 is a reply to message #106529] Wed, 19 March 2008 15:23 Go to previous messageGo to next message
Simon Kaegi is currently offline Simon KaegiFriend
Messages: 381
Registered: July 2009
Senior Member
Glad you figured it out.
As you've discovered the parameter on the end is a context path.
You can't use the wildcard character here, only for the URI alias.

"Setya" <jsetya@gmail.com> wrote in message
news:a6870ceb5a3636530641a8fb349b8761$1@www.eclipse.org...
> Hi,
>
> After digging the source code for quite sometime, I've got it working by
> changing the ext. point registration into:
>
> <servlet alias="/*.jsp"
> class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/web "/>
>
> And I can acess the page using url :
> http://localhost:8080/main.jsp
>
> Best Regards,
>
> Setya
>
Re: Registering JspServlet via ext. point [message #106604 is a reply to message #106571] Wed, 19 March 2008 16:24 Go to previous message
Setya Nugdjaja is currently offline Setya NugdjajaFriend
Messages: 567
Registered: July 2009
Senior Member
Simon,

Thanks,

> Glad you figured it out.
> As you've discovered the parameter on the end is a context path.
> You can't use the wildcard character here, only for the URI alias.

But from the example pointer earlier why the alias is '/ext/*.jsp' instead
of '/*.jsp' ? Since I can't find /ext folder anywhere ?

Regards,

Setya
Previous Topic:Finding bundles
Next Topic:Log Service Status
Goto Forum:
  


Current Time: Sat Oct 16 13:09:55 GMT 2021

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

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

Back to the top