Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Communication between a Servlet and a custom protocol

Hi,

On Mon, Jan 20, 2020 at 12:36 AM Josh Spiegel <joshlakewg@xxxxxxxxx> wrote:
>
> Hi,
>
> What is the cleanest way for a servlet (e.g. in a war file under webapps) to communicate state with a custom ConnectionFactory running in the same server?

A custom ConnectionFactory typically creates Connections that parse
bytes that have been read from the network.
If that's the case, then your servlet should open a socket and write
the custom protocol bytes so that they can be read and parsed by the
custom Connection - basically you have to write a client for your
custom protocol.

> Is there is some way to set Server attributes from the servlet or something like that?

You need to detail what you want to do here, and consider the
lifetimes of the objects you want to deal with.
You do not want that a second request to the servlet overwrites the
attribute set by the first request.

> A static variable would probably work for me but I am hoping for something that is more decoupled and scoped at the Server level.

I doubt a static will work - would not be overwritten for every request?

Can you detail the problem first, rather than the solution?

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top