• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Websocket servlet context

 
Greenhorn
Posts: 18
jQuery Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm currently checking out the Tomcat 7 websockets and got them working smoothly. But I have a design question about the different contexts: The websocket handling is done in a separate servlet context from where I don't have access to the current View context of the page bean. Is there a way to access the data on the view scoped bean related to the page that initiated the websocket message? Or am I following a wrong design pattern? I couldn't find any examples on the web that illustrate this point.

Regards, Paul.
 
Saloon Keeper
Posts: 27763
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"View scope"? Is this supposed to be JSF?

In any event, if you have other servlets/JSPs active while a websocket is in play, they can share data via the HttpSession and/or Application scope objects.

I would not include the websocket code directly in a servlet, JSP or GUI interface objects (Model, View definitions) for the same reason that I don't include complex business functions there. It's cleaner to have one function/one module.
 
Paolo Rodeo
Greenhorn
Posts: 18
jQuery Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

Thanks for your answer. Indeed, I forgot to mention I'm talking JSF. Could you please elaborate a bit more about how to use session or application objects to communicate? For instance, if a message arrives on the websocket, the socket's servlet callback "MessageInbound.onTextMessage(CharBuffer)" is called. You suggest not to include any business login in there. Sounds good, but then allow me to rephrase my original question: What's then the proper way to activate the business logic in the view scoped bean? Or: How to pass messages asynchronoulsy from one context (socket servlet) to another (view bean), v.v.?

Regards, Paul
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic