Not sure how well this will work from WebSockets, but usually to accomplish
calling another servlet from the current servlet without a socket
connection requirement I would use the RequestDispatcher object.

Using the 
ServletContext#getRequestDispatcher(String)<http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/ServletContext.html#getRequestDispatcher(java.lang.String)>to
obtain a
RequestDispatcher<http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/RequestDispatcher.html>object,
you could then call the
dispatcher.forward(Request,Response)<http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.5/docs/servlet-2_5-mr2/javax/servlet/RequestDispatcher.html#forward(javax.servlet.ServletRequest,
javax.servlet.ServletResponse)> to make a remote call.

>From a WebSocket you'd need to create an HttpServletRequest and
HttpServletResponse object suitable for making that call tho, which could
be the tricky part.

--
Joakim Erdfelt
[email protected]

http://webtide.com | http://intalio.com
(the people behind jetty and cometd)



On Tue, Feb 28, 2012 at 3:39 PM, Jeremy Johnson <
[email protected]> wrote:

> Ok, I acknowledge this may come across as an odd question.****
>
> ** **
>
> In an embedded Jetty process, is there a way to programmatically generate
> an HTTP request and receive a response without resorting opening a socket
> e.g. HTTPUrlConnection?****
>
> ** **
>
> Why on earth would I want to do such a thing?****
>
> ** **
>
> I have a RESTful web service implemented with Jersey and server up by
> embedded Jetty.  In the same embedded Jetty process I’ll also be serving
> WebSocket connections, likely speaking my own subprotocol.****
>
> ** **
>
> As part of the subprotocol I’d like for WebSocket clients to have the
> ability to perform CRUD operations on my web service resources.  I’m
> considering different ways to skin this cat, one of which being to push an
> appropriate HTTP request for the web service to Jetty and return the
> results to the WebSocket client.  Since both the WebSocket and web service
> are running in the same process, on the surface it seems that there would
> be performance advantages to accomplishing this though a method call rather
> than hitting the network.****
>
> ** **
>
> Better ideas are certainly welcome.****
>
> ** **
>
> Thanks!****
>
> ** **
>
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to