1 Reply Latest reply on Aug 13, 2008 7:29 PM by Damian Harvey

    How to store variables within seam sessions. How to use regular servlets with seam.

    Clement yew Newbie

      Hi There.

      I'm relatively new to JBoss seam. I find that it has a lot of potential. However, I have some problems and can't seem to find documentation anywhwere.

      I'm trying to develop a facebook app on top of JBoss seam. However, I would want a way to save the facebook session somewhere so that I could reuse it at other pages. So here's my problems listed down :

      1. How to store the sessionKey(Obtained from facebook) so that I could reuse it in other pages/servlets/jsfs. Can I use the contexts provided by seam (Stateless,statefull, application, conversation, etc)?

      2. I have managed to integrate regular servlets into seam using ContextualHttpServletRequest. However, how can i use the bijections within servlets?
      For example, in jsf, i can use  ${user.username}. Then, in the bean, i use the @In / @Out annotations. How can I achieve the same thing in servlets?

      I hope any experts could help me with this. It'll be much appreciated.


        • 1. Re: How to store variables within seam sessions. How to use regular servlets with seam.
          Damian Harvey Apprentice

          I haven't looked at anything to do with FaceBook Apps but:

          1) You can use any of these contexts depending on how long you want the sessionKey to stick around for. Given it's name, I'd think the session context sounds most likely. Either outject it into the Session context eg;

          private String sessionKey;

          or set it yourself inline in a method:

          Contexts.getSessionContext().set("sessionKey", sessionKey);

          2) You could do the whole thing with servlets, but it sounds painful. In a servlet you can access Seam components like this:


          but you may find it more useful just to have Seam Beans (SLSB, SFSB, POJO, whatever) and get the ServletResponse eg:

          public void someAction() {
             try {
                final HttpServletResponse resp = (HttpServletResponse) facesContext.getExternalContext().getResponse();
                resp.getOutputStream().write(...whatever you want...);
             } catch (IOException e) {