[jboss-user] [JBoss Seam] - Re: Servlets in long running conversations

andrey.chorniy do-not-reply at jboss.com
Wed Jan 23 20:17:51 EST 2008


I have some news. it is start working for me, but to achieve that I have to add cookie parameter JSESSIONID to identify the session in which that conversation was originally created.

ContextFilter and the underlying code uses the HTTP-Session to restore Conversation-Entries.

If I make request with plain http-get request like:
http://server-host/context/servlet/some-servlet?cid=2
from another browser - it doesn't work. 

If I use two tabs of FireFox - in the first tab I open the conversation, in the second I make a servlet-request - IT WORKS.

So, it start working after I've added JSESSIONID cookie to my call servlet-request.
I make a programmatic call (not a browser reauest), so I have control over cookies.
But it seems that it is impossible to do it if you don't know the JSESSIONID value or have no controll over cookies. To do it via plain URL approach you have to turn-off cookies in the browser to add the jsessionid parameter to the get-request.
>From one side - it add some additional security, from the other side - you not always can use it, since you are not always can establish the HTTPSession for that


Here is the code which is used to load current Conversation context.
It is stored in the sessionContext, which is based on the HTTPSession object

org.jboss.seam.contexts.Lifecycle
  |    public static void beginRequest(ServletContext servletContext, HttpSession session, ServletRequest request) 
  |    {
  |       log.debug( ">>> Begin web request" );
  |       Contexts.eventContext.set( new WebRequestContext( ContextAdaptor.getRequest(request) ) );
  |       Contexts.sessionContext.set( new WebSessionContext( ContextAdaptor.getSession(session) ) );
  |       Contexts.applicationContext.set( new WebApplicationContext(servletContext) );
  |       Contexts.conversationContext.set(null); //in case endRequest() was never called
  |    }
  | 
  | org.jboss.seam.core.ConversationEntries 
  |    public static ConversationEntries instance()
  |    {
  |       if ( !Contexts.isSessionContextActive() )
  |       {
  |          throw new IllegalStateException("No session context active");
  |       }
  |       return (ConversationEntries) Component.getInstance(ConversationEntries.class, ScopeType.SESSION);
  |    }
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122867#4122867

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122867



More information about the jboss-user mailing list