Hi..
According to jetty Web application architecture,
ServletHandler is located in the lastest..
So, I tried to adapt DefaultHandler to WebSocketHandler... but it didn't
work..
I don't know why...
Is really there no way except Servlet for WebSocket..?
This is my source..
-------------------------------------------------------------
public class PocWebSocketServletContextListener implements
ServletContextListener{
private Server server;
@Override
public void contextDestroyed(ServletContextEvent arg0) {
if (server != null) {
try {
// stop the Jetty server.
server.stop();
} catch (Exception e) {
e.printStackTrace();
}
}
}
@Override
public void contextInitialized(ServletContextEvent arg0) {
System.out.println("PocWebSocketServletContextListener has received
a servlet context event.");
try{
this.server = new Server(8081);
PocWebSocketHandler handler = new PocWebSocketHandler();
handler.setHandler(new
org.eclipse.jetty.server.handler.DefaultHandler());
server.setHandler(handler);
server.start();
}catch(Throwable e){
e.printStackTrace();
}
}
}
--------------
public class PocWebSocketHandler extends WebSocketHandler{
public PocWebSocketHandler(){
System.out.println("PocWebSocketHandler is created.");
}
@Override
public WebSocket doWebSocketConnect(HttpServletRequest arg0, String
arg1) {
return new PocWebSocket();
}
}
---------------------------------------
Thanks in advance.
Sunny
On Wed, Jan 11, 2012 at 4:35 AM, Simone Bordet <[email protected]> wrote:
> Hi,
>
> On Tue, Jan 10, 2012 at 20:25, Hendrik Schenk <[email protected]> wrote:
> > Oh...how stupid of me!
> >
> > So it was correct what i did. thank you for your help.
> >
> > And a servlet is the correct way to use websockets in jetty? or is there
> > another way?
>
> WebSocketServlet is the best way.
>
> Simon
> --
> http://cometd.org
> http://intalio.com
> http://bordet.blogspot.com
> ----
> Finally, no matter how good the architecture and design are,
> to deliver bug-free software with optimal performance and reliability,
> the implementation technique must be flawless. Victoria Livschitz
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
--
----------------------------------------------------------------------------------
*Seonhong Ahn*
Director of Research and Development
*Collabra Co.*
960-6 Deachi-dong, Gangnam-gu, Seoul, Korea 135-280
Tel. 82-70-8670-6929 Fax. 82-2-6280-4807
*Mobile 82-10-8292-3923*
E-mail [email protected] / [email protected]
www.collabra.co.kr
----------------------------------------------------------------------------------
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users