Thanks for the detailed info. as this is inherited, I will have to look 
deeper and see what more was done in order to understand how to migrate.

Alain

On Tuesday, April 25, 2023 at 7:01:41 AM UTC-4 [email protected] wrote:

> Hello
>
> In Pax Web before 8, org.ops4j.pax.web.jsp.JspServletWrapper wraps 
> original org.apache.jasper.servlet.JspServlet - the reasons are: special 
> org.ops4j.pax.web.jsp.JasperClassLoader to scan bundles (this is done much 
> better and more consistently in Pax Web 8) and special handling of "jsp 
> files" (these are handled in standard way in Pax Web 8).
>
> In Pax Web 8, org.ops4j.pax.web.jsp.JspServlet extends 
> org.apache.jasper.servlet.JspServlet - the main (only) reason is that TCCL 
> is set to proper OSGi classloader around init() and service() calls.
>
> org.apache.jasper.servlet.JspServletWrapper is repackaged both in Pax Web 
> 8 and Pax Web 7 - this is simply because pax-web-jsp bundle adds 
> `org.apache.jasper.servlet` as exported package without import.
> Generally JSP handling was a bit tricky (both in Pax Web 7 and 8) because 
> there was a conflict between modular OSGi philosophy and JavaEE consistency 
> (taglib scanning for example).
>
> If you want to instantiate "jsp servlet" it's better to do it with 
> org.ops4j.pax.web.jsp.JspServlet class from pax-web-jsp. However - for 
> WABs/WARs, this servlet is instantiated automatically if pax-web-jsp bundle 
> is installed and your JSPs will just work.
> For HttpService / Whiteboard approach, you can use these examples/snippets:
>
> HttpService:
>
> org.ops4j.pax.web.service.WebContainer service = ...; // obtain OSGi 
> service of org.ops4j.pax.web.service.WebContainer class 
> (org.osgi.service.http.HttpService extension)
> wc.registerJsps(new String[] { "*.jsp", "*.JSP", ... }, null, null);
>
> Whiteboard:
>
> org.ops4j.pax.web.extender.whiteboard.runtime.DefaultJspMapping mapping = 
> new org.ops4j.pax.web.extender.whiteboard.runtime.DefaultJspMapping();
> mapping.setUrlPatterns(new String[] { "*.jsp", "*.JSP", ... });
> ServiceReference<org.ops4j.pax.web.service.whiteboard.JspMapping> ref = 
> context.registerService(org.ops4j.pax.web.service.whiteboard.JspMapping.class,
>  
> mapping, null);
>
> org.ops4j.pax.web.extender.whiteboard.runtime.DefaultJspMapping Whiteboard 
> service has setJspFile() setter that could be used to implement "jsp files" 
> in the meaning of web.xml's:
>
> <!--
>     This servlet doesn't have a class, only a JSP file. It'll be converted 
> to use real JSP servlet with jspFile init parameter
> -->
> <servlet>
>     <servlet-name>jsp-info</servlet-name>
>     <jsp-file>/jsp-info.jsp</jsp-file>
> </servlet>
>
> (see: 
> https://github.com/ops4j/org.ops4j.pax.web/blob/web-8.0.20/samples/samples-war/war-most-complex/the-wab-jar/src/main/resources/META-INF/web-fragment.xml
> )
>
> regards
> Grzegorz Grzybek
>
> wt., 25 kwi 2023 o 12:33 Alain Picard <[email protected]> 
> napisał(a):
>
>> I'm currently working to migrated from 7.2.26 to 8.0.20 and I get a 
>> compile error with the import of "org.ops4j.pax.web.jsp.JspServletWrapper"
>>
>> From what I can see, pax-web now packages 
>> "org.apache.jasper.servlet.JspServletWrapper" in the pax-web-jsp bundle. 
>>
>> First, maybe since it is referencing apache code, the source bundle is 
>> missing this part of the code. 
>>
>> Secondly, should we replace one for the other or should we use the new 
>> org.ops4j.pax.web.jsp.JspServlet that seems to be a wrapper in itself and 
>> if so how do we instantiate it.
>>
>> Here is what we currently have (which I've inherited and has no real 
>> explanation with it) as to why this was required
>>
>> JspServletWrapper servletWrapper = new 
>> JspServletWrapper(ViewerPlugin.getDefault().getBundle(), _jspPath);
>> servletWrapper.init(servletConfig);
>> ServletResponse serviceResponse = response;
>>
>> AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
>> @Override
>> public Boolean run() {
>>   try {
>>     servletWrapper.service(baseRequest, serviceResponse);
>>   }
>>   catch (Exception e) {
>>     LOG.debug("Error serving jsp page", e); //$NON-NLS-1$
>>   }
>>   return true;
>>        }
>> });
>>
>> Thanks
>> Alain
>>
>> -- 
>> -- 
>> ------------------
>> OPS4J - http://www.ops4j.org - [email protected]
>>
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "OPS4J" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ops4j/046e0384-e2c4-40b5-afe7-cee65366d063n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ops4j/046e0384-e2c4-40b5-afe7-cee65366d063n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
-- 
------------------
OPS4J - http://www.ops4j.org - [email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ops4j/a13aa0ae-c256-4bed-abe4-fb3985a24f2dn%40googlegroups.com.

Reply via email to