You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Kartweel <rh...@exemail.com.au> on 2012/05/09 05:12:08 UTC

Getting Session State Object from another servlet alongside Tapestry

Hi,

I've got another servlet running alongside tapestry. I would like to get a
sessionstate object from Tapestry to find out the currently logged in user
(And probably a few other things too eventually).

I've accessed the Service registry and can build the ApplicationStateManager
service, but on requesting an object I get the exception below. Which makes
perfect sense, because the request hasn't gone through the tapestry pipeline
(I'm using a tapestry ignorefilter to ignore requests to the other servlet).

So my question is, can I somehow inject the request information into
tapestry so I can access the tapestry session state object?. Or is there a
better way to integrate the other framework to use some more tapestry
features? I understand session objects integrate with the tapestry page
lifecycle, so it might not be so straight forward, but if I could just
access the objects and later work on setting them, then that would be great
:).

My goal is to embed a few Vaadin pages into my tapestry application. So far
so good, I can access services, but it would be great to access the session
related objects too.

Thanks, Ryan


java.lang.NullPointerException: Unable to delegate method invocation to
property 'request' of <Proxy for
RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>, because the
property is null.
	at $Request_ab8a69b42eedd.readProperty(Unknown Source)
	at $Request_ab8a69b42eedd.getSession(Unknown Source)
	at $Request_ab8a69b42eea3.getSession(Unknown Source)
	at
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getSession(SessionApplicationStatePersistenceStrategy.java:38)
	at
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.getOrCreate(SessionApplicationStatePersistenceStrategy.java:49)
	at
org.apache.tapestry5.internal.services.SessionApplicationStatePersistenceStrategy.get(SessionApplicationStatePersistenceStrategy.java:44)


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting Session State Object from another servlet alongside Tapestry

Posted by Lance Java <la...@googlemail.com>.
This is interesting because I will probably be doing the same thing soon to
integrate the DWR servlet with tapestry. I guess you will need to
instantiate the servlet and set the "init-params" on it. I was thinking of
configuring the values as  http://tapestry.apache.org/symbols.html tapestry
symbols  and passing them as init-params to the servlet.

NB. To deal with a servlet you will be needing HTTPServletRequest and
HTTPServletResponse so it is better to implement a
org.apache.tapestry5.services.HttpServletRequestFilter and contribute it to
the HttpServletRequestHandler instead of contributing a RequestFilter to the
RequestHandler as I suggested before (on works with the raw servlet objects
and the other works with tapestry's wrapper objects).

I'm guessing that you will map the servlet to a path (eg "/vaadin/.*") and
will only pass to the servlet for paths that match (and return true) or
return false otherwise to allow tapestry to process the request.

I'm interested to hear how you get along as I will be doing the 
http://tapestry.1045711.n5.nabble.com/tapestry-push-proof-of-concept-td5697644.html
same thing soon .

Cheers,
Lance.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5702313.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting Session State Object from another servlet alongside Tapestry

Posted by Kartweel <rh...@exemail.com.au>.
Thanks. That seems like a better approach, rather than ignoring it, to 
still process it but pass it onto the other servlet. I guess the trick 
is making the request filter pass it into Vaadin, so I need to find out 
how Vaadin needs it to work. I guess instantiate the Vaadin servlet and 
just pass the request on?. I'm sure I'll figure it out :).

On 9/05/2012 4:13 PM, Lance Java [via Tapestry] wrote:
> Instead of implementing a HttpServletRequestFilter that is not managed 
> by tapestry, you could contribute a 
> org.apache.tapestry5.services.RequestFilter instead.
>
> In your AppModule add the following
>
>     public void 
> contributeRequestHandler(OrderedConfiguration<RequestFilter> configuration) 
> {
>         configuration.addInstance(MyRequestFilter.class);
>     }
>
> Here's some further reading:
> http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/RequestFilter.html
> http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/internal/services/StaticFilesFilter.html
> http://tapestry.apache.org/request-processing.html
>
> ------------------------------------------------------------------------
> If you reply to this email, your message will be added to the 
> discussion below:
> http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5696736.html 
>
> To unsubscribe from Getting Session State Object from another servlet 
> alongside Tapestry, click here 
> <http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5696382&code=cmhvd0BleGVtYWlsLmNvbS5hdXw1Njk2MzgyfDE5MTMyMDEzNjQ=>.
> NAML 
> <http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml> 
>


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5702040.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

Re: Getting Session State Object from another servlet alongside Tapestry

Posted by Lance Java <la...@googlemail.com>.
Instead of implementing a HttpServletRequestFilter that is not managed by
tapestry, you could contribute a org.apache.tapestry5.services.RequestFilter
instead.

In your AppModule add the following

    public void contributeRequestHandler(OrderedConfiguration<RequestFilter>
configuration) {
        configuration.addInstance(MyRequestFilter.class);
    }

Here's some further reading:
http://tapestry.apache.org/5.3/apidocs/org/apache/tapestry5/services/RequestFilter.html
http://tapestry.apache.org/5.3/apidocs/src-html/org/apache/tapestry5/internal/services/StaticFilesFilter.html
http://tapestry.apache.org/request-processing.html

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5696736.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting Session State Object from another servlet alongside Tapestry

Posted by Kartweel <rh...@exemail.com.au>.
Using the code in that post (and updating it for T5.3) seems to work. But I
don't know why... am I going to create a memory leak?. In my other servlet I
can call registry.cleanUpThread() at the end of every request. Now just the
fun of trying to kinda link a page based framework like tapestry with more
of a desktop style framework like vaadin.

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5696405.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Getting Session State Object from another servlet alongside Tapestry

Posted by Kartweel <rh...@exemail.com.au>.
Found a similar post here. Any advice? :)

http://osdir.com/ml/users-tapestry-apache/2009-12/msg00140.html


--
View this message in context: http://tapestry.1045711.n5.nabble.com/Getting-Session-State-Object-from-another-servlet-alongside-Tapestry-tp5696382p5696398.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org