Fork me on GitHub
#ring
<
2023-11-10
>
John16:11:06

I've searched the web and Slack and failed to figure out how to serve a standard Servlet from a Java library under a router/server started by Ring. It seems this question comes up every now and again, but as a newbie I couldn't assimilate any partial answers into a final one

John16:11:36

I know the other way around is made easy via the servlet util functions in Ring

John16:11:00

maybe I just make an annotated WebServlet class and Jetty will find it ?!

John16:11:14

ring's jetty adapter does produce a standard contexthandler which I think has a mount-like thing after it started think_beret

weavejester17:11:56

It depends on the adapter being used. If you use the default Jetty adapter, you get back a Jetty Server object. Once you've got that, I believe you can use insertHandler to wrap Ring's Jetty handler class in a HandlerWrapper , and then you can use setHandler on that wrapper to add a ServletHandler, and then finally to use addServletWithMapping.

🙇 1
John02:11:30

So, got the Servlet -classed object, made a org.eclipse.jetty.servlet.ServletHandler and a org.eclipse.jetty.servlet.ServletHolder , added the servlet to it, stopped the server, .setHandler on it and restarted. The insertHandler I imagine will both make it ergonomic to keep the original handler and not have to restart but I didn't experiment that far yet, just saw that the above was working

John02:11:12

oh and yeah, addServletWithMapping

RAJKUMAR23:11:42

Hi, I've question related ring and the related libraries

RAJKUMAR23:11:23

Any reason the library Ring JSON/0.5.1 is not updated with ring-core currently used version is 1.9.2 ring-headers/0.3.0 is not updated with ring-core currently used version is 1.6.0

weavejester04:11:42

They just haven't been updated yet.

RAJKUMAR06:11:55

do you have any plans to release it in near future?

weavejester14:11:34

I guess once Ring 1.11 has been released I can go through and update them. But why does it matter? If you're using those libraries presumably you also have a Ring dependency in your project anyway, and that will override the older dependencies in those libraries.