File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes share session data between portlets and a jsp of the portal theme Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "share session data between portlets and a jsp of the portal theme" Watch "share session data between portlets and a jsp of the portal theme" New topic
Author

share session data between portlets and a jsp of the portal theme

Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
Hello!
sorry for my English.
I'm new using portlets.I have a problem.
I'm using portlets and a websphere portal server.
I have a jsp in the theme of my portal and in this jsp i call a java class to save an attribute into the session.
Now using portal url generation i go to a portlet and i want to read and modify the attribute i saved before from the jsp of the theme, but I have read that the session is not shared between different applications.
How can I fix this?
thanks
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"natt natt",
Please check your private messages regarding an important administrative matter.
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Ajith Prasad
Ranch Hand

Joined: Aug 22, 2006
Posts: 66
Did you store session in Application scope, then you must have share the session allover the web application
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Application scope? I think that only shares the data across portlets in a common war file, not to all portlets in the application.


Part of being a good portal developer is to think like a portal developer.

Portlets should be very much stand-alone. Some may interact at some level with other portlets, but interacting with a variable in a theme? Well, that's really pushing it.

To develop portlets, you've got to think like a portlet developer, and not like a typical servlet/JSP developer.

Maybe you could tell us why you need to do this? Maybe then we can figure out a better solution. As far as how goes, well, other than casting a PortletSession back into an HttpSession (and configuring the server to share sessions across all we apps), there's probably not much of a way. Maybe a centralized database table the theme and the portlet can read from? Eitehr way, these aren't very elegant solutions, and likely wouldn't pass an architecture review.

Why do you need to do this?

-Cameron McKenzie
[ April 28, 2008: Message edited by: Cameron Wallace McKenzie ]
Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
I know it wasn�t a good idea, but the client didn�t want to search a better solution.
Finally they accept store in the database the value and recover it when it is necessary.
Thanks for your answers.
Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
Now the client don�t want to use the database.
My problem is they have a combobox in a jsp of the portal theme and when you change the value in the combo I have to redirect to a portlet that uses this value to make a search and after this comunication the portal has been reload and in the combo the value is not the selected one.
It's very difficult to explain the problem.
Thanks
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Get it out of the theme!

Can you create a portlet that is always in the top right hand corner of the page? A small one that no user has rights to remove? Then it's always there.

Look at my website, Website with Search Field in top left hand corner

I've got a search portlet in the top left hand corner that allows you to search google. It's always there, but it's fairly innocuous, and it doesn't disturb the user's experience. Why not do something like that?

Get this functionality out of the theme. It sounds like the theme is the wrong place. Themes should provide a common look and feel, but not really provide any real functionality other than that. Certainly communicating with a portlet is a no-no.

-Cameron McKenzie
Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
I know this is the better solution, but the client at the moment don�t want to change what they have.
If I create the new portlet how can I pass the value to other portlet that is in other war?
I can see you are a good professional developper.
thanks.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Data stored in the PortletSession scope can be shared with portlets inside the same war, but not outside.

When it comes to sharing data, you've got to 'roll your own' and create your own solution.

One way is to use a common, temporary, database table. Use the portletID and clientID to create a unique entry for the user to uniquely identify a client's data. Save client specific information to this table when it comes in, and then read this table when you need it. Any portlet can connect to a JDBC database.

It's a bit more work, because you're not using the portlet API framework, but you can do it.

Good luck!

-Cameron McKenzie
Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
Thank you very much!!
Vito Andolini
Greenhorn

Joined: Jun 19, 2007
Posts: 10
Cameron is going to think I'm stalking him, but wouldn't cooperative portlets be acceptable here, too?

If an action is taken on his "drop down" portlet, it can communicate information to the target portlet. I suppose if the communication needs to be "inter-page", then the availability of that functionality will depend on the Portal vendor.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

I like cooperative portlets when they're the right approach.

Indeed, technologies like C2A from IBM allow portlets to talk to each other. It might tie you into a vendor, it might not be available in the future, and even if it is, it might be very difficult to find people who can maintain applications that use Click to Action - it's definitely a unique skill.

But I've worked on a few portal projects where the girls were Whiz-Bang, and were more than capable of implementing, using and maintaining C2A. It worked pretty good.

-Cameron McKenzie
Vito Andolini
Greenhorn

Joined: Jun 19, 2007
Posts: 10
You are correct. I was mistakenly under the impression that while C2A was an IBM implementation, JSR-168 included Cooperative Portlets in its spec. That was incorrect, and your assertions are valid.

Thanks for the input!
Natt Gonzalez
Ranch Hand

Joined: Apr 28, 2008
Posts: 31
Hello!
Because my client didn't want to change the theme of the portal we found an IBM solution.
This is the link.

http://www.ibm.com/developerworks/websphere/library/techarticles/0602_hepper/0602_hepper.html

It worked with applications in different wars.
Maybe in the future they would change the solution and use portlets in the same war and use the session correctly.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: share session data between portlets and a jsp of the portal theme
 
Similar Threads
portlet
Developing Portal and Portlet
Speed Up WebSphere Portal - action-precompile-jsp
using css in my portal
hide a portlet when click on other portlet