Hi Peter,

Glad you found this example useful as to how HTML5 pushstate can be
achieved with Jetty. The XML version is quite different as you can see and,
unfortunately, I don`t have as much experience with it. I was using
Tomcat + XML before we switched to microservices and Embedded Jetty. I
never really used XML configuration with Jetty.

I still gave a look at the snippet you included and if passing arguments to
a handler is in fact allowed, then I think you may be on the right path.
Perhaps someone on this list knows what to do in order to get a reference
to the context.

An alternative to using parameters would be to use annotations directly in
the handler class. I assume that your backend is already using annotations
for your servlets etc. Perhaps its possible that Jetty will scan for
annotations in rewrite handlers as well? I am really not sure about this,
just trying to give you another possibility to look at.

If you're stuck and must use XML descriptors but are flexible on the JEE
implementation, I know that Tomcat has a better URL rewriting method. It
uses the same rewrite format as Nginx which allows conditional statements.
You could easily do a prototype to verify this and then make the switch if
it proves useful. Here's a link to the page showing that conditional
rewrite is supported on Tomcat:
https://tomcat.apache.org/tomcat-8.0-doc/rewrite.html

The following has nothing to do with your question, just a bit of a thought
at a macro scale. Can your app be converted to a microservice?  I
personally have had a much better experience since I moved away from the
application server model. I find myself with more options and more
flexibility when it comes to keeping up with ever changing technology
trends.

Should I had failed to find the rewriting solution I shared previously, I
would have decoupled my web ui from my backend and moved forward as follows:

1) host the angular application on nginx and let the javascript client
connect to the backend through REST APIs or websocket only.
2) host backend on standard JEE container with only a clean cut API to
worry about. No server pages. Easy to test the API and increase code
coverage.

I've seen this model in use and it works quite well. Nginx is excellent at
hosting frontend apps.  JEE is excellent at hosting backend apps. Best of
both worlds and scalable too.

That being said, I hope you'll find a solution and please share it with us
if you find one!  I'd be interested in knowing how it can be done via XML.

Cheers,

*Nicolas Therrien*

Senior Software Developer

*[image:
https://www.motorolasolutions.com/content/dam/msi/images/logos/corporate/msiemailsignature.png]*

*o*: +1.819.931.2053


On Fri, Nov 30, 2018 at 1:49 PM PETER CURRIVAN <[email protected]>
wrote:

> Nicolas Therrien et al.,
>
>
>
> Thank you for sharing your custom RewriteHandler for use with Angular 6
> routing.  I am having trouble using it, however, because I am using XML
> configuration (non-embedded Jetty).  My problem is I do not know how to
> access a reference to the WebAppContext in my jetty-rewrite.xml file.
> Whereas you have instantiated the WebAppContext and the
> Html5PushStateConditionalRewriteHandler in a single Java file, and can
> simply pass the reference, I am seemingly forced to configure these objects
> in separate Jetty IoC XML files (jetty-web.xml configures the WebAppContext
> and jett-rewrite.xml configures the
> Html5PushStateConditionalRewriteHandler).
>
>
>
> Do you (or anyone else reading this) know a way I might access a reference
> to the WebAppContext configured in jetty-web.xml from within
> jetty-rewrite.xml?  Or perhaps another way to access the “mappedServlet”
> within the custom RewriteHandler?
>
>
>
> I tried adding an id to the WebAppContext in jetty-web.xml and using a Ref
> tag in jetty-rewrite.xml but the reference comes back null.
>
>
>
> jetty-web.xml:
>
> …
>
> <Configure id="webAppContext"
> class="org.eclipse.jetty.webapp.WebAppContext">
>
> …
>
>
>
> jetty-rewrite.xml:
>
> …
>
> <Configure id="Server" class="org.eclipse.jetty.server.Server">
>
>   <Call name="insertHandler">
>
>     <Arg>
>
>       <New class="my.package.Html5PushStateConditionalRewriteHandler">
>
>         <Arg name="webAppContext"><Ref refid="webAppContext"/></Arg>
>
> …
>
>
>
> Thanks,
>
> Peter Currivan
> _______________________________________________
> jetty-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.eclipse.org_mailman_listinfo_jetty-2Dusers&d=DwICAg&c=q3cDpHe1hF8lXU5EFjNM_A&r=P3_1pTtMQK06fFymYIWbyyzVU6nc0CcwfuZhLhexammvaiCaU0ieHeI7BWvfbbjE&m=Whwhzf2Dpi3RaUUDZwzWF0VV3CKHexK0i9qITo3-yIA&s=yg8hFh1RvW761mam8bB5sHTgAr7WOZp_c7aEwsedDvE&e=
_______________________________________________
jetty-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://www.eclipse.org/mailman/listinfo/jetty-users

Reply via email to