Sharing data between portlets and servlets
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > WebSphere > WebSphere Portal Server > Sharing data between portlets and servlets




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Sharing data between portlets and servlets  
Bryan Hogan


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-20-04 10:36 PM

Is there a simple and clean way to share data between a portlet and servlet
using WPS 5.0.2 API.

Our particular scenario is as follows:
- PortletA stores information into the PortletSession
- PortletA renders JSP/HTML containing an <IMG> or <EMBED> tag that
references ServletB.  ServletB is included in the same web application.
- ServletB requires PortletA session information in order to properly
complete

Q:  How can ServletB access session information stored by PortletA?

I see that the PortletSession interface for JSR 168 allows the developer to
specify a "scope" when setting and getting attributes from the session.  The
WPS version of PortletSession does not currently include this feature.

I also see that the PortletSessionImpl classes include a method named
'getHttpSession()' which will return the base HttpSession.  Storing shared
information into the base HttpSession would solve our problem; however, we
would prefer not make hardcoded references to the implementation class in
our code.

I suspect that others have encountered this issue.  What is the best way to
deal with it?


Thanks,
Bryan Hogan








[ Post a follow-up to this message ]



    Re: Sharing data between portlets and servlets  
Brian Lalor


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-21-04 10:39 PM

Bryan Hogan wrote:

> I also see that the PortletSessionImpl classes include a method named
> 'getHttpSession()' which will return the base HttpSession.  Storing shared
> information into the base HttpSession would solve our problem; however, we
> would prefer not make hardcoded references to the implementation class in
> our code.

That's either broken, or I don't understand it.  When you use
getHttpSession(), you *do* get an HttpSession object, but the keys
stored in the object are prefixed with what is probably the unique id of
the portlet application (not sure about that, but it sure isn't what I
put in there).  For example, if you do
getHttpSession().setAttribute("foo", "bar")
when you iterate through getHttpSession().getAttributes() you see
something like "7_A_3_foo".

> I suspect that others have encountered this issue.  What is the best way t
o
> deal with it?

I used a single bean for sharing information between the portlet and the
servlet.  Then, in the servlet, I iterated through all values in the
session and matched the class against the class of the bean.  Not
terribly elegant, but it did work...

B





[ Post a follow-up to this message ]



    Re: Sharing data between portlets and servlets  
Jon Mell


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-22-04 10:37 AM

You can try using the servlet context. Michael Harris had posted some info
on how to use this earlier.

Jon

"Bryan Hogan" <bryanh@nospam.ibm.com.zzz> wrote in message
news:c8j4lf$5d24$1@news.boulder.ibm.com...
> Is there a simple and clean way to share data between a portlet and
servlet
> using WPS 5.0.2 API.
>
> Our particular scenario is as follows:
> - PortletA stores information into the PortletSession
> - PortletA renders JSP/HTML containing an <IMG> or <EMBED> tag that
> references ServletB.  ServletB is included in the same web application.
> - ServletB requires PortletA session information in order to properly
> complete
>
> Q:  How can ServletB access session information stored by PortletA?
>
> I see that the PortletSession interface for JSR 168 allows the developer
to
> specify a "scope" when setting and getting attributes from the session.
The
> WPS version of PortletSession does not currently include this feature.
>
> I also see that the PortletSessionImpl classes include a method named
> 'getHttpSession()' which will return the base HttpSession.  Storing shared
> information into the base HttpSession would solve our problem; however, we
> would prefer not make hardcoded references to the implementation class in
> our code.
>
> I suspect that others have encountered this issue.  What is the best way
to
> deal with it?
>
>
> Thanks,
> Bryan Hogan
>
>
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:01 PM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register