I've been surfing the Internet the whole day but haven't found a proper answer to my question / problem yet.
Hope you guys can help me: :-)
I have two Portlets A and B. I want Portlet A to display Portlet B in the _same window_ when a user clicks on an URL in Portlet A. The user can return to Portlet A again by clicking on an URL in Portlet B.
Is it possible to display two Portlets in one window sequentially?
No what you are asking for is completely and totally impossible.
Essentially, you want a user to add a portlet to a page. When they click on a url in that portlet, the portlet then should remove itself from the page entirely, which is actually a portal administrative task, and then, add a new portlet, to the same page, in it's place. Then, when a url in this second portlet is clicked, the portlet removes itself entirely from the page, causing all sorts of administrative steps to happen in the background, and then the new portlet appears. Lets not even get into the fact that when a portlet is removed from a page, all of the PortletPreferences or PortletData information is completely removed. Essentially, you'd have to write your own portal server to make this type of thing possible.
However, maybe your portlet has two JSP pages. When a link in one JSP is clicked, the second appears. When a link in the second JSP is clicked, the first one appears. The flow is managed by the portlet class, which correctly would be acting as a controller. I think this would be easier than trying to completely re-engineer a portal server.
Okay, my response is fairly snide and tongue in cheek. The fact is, with a portlet, you have to shift your mind a bit and think differently. It isn't a JSP/Servlet application anymore. But don't overcomplicate things. Keep it simple.
And just to note, with a live portal, portlets are very, very, very rarely ever added or removed from a page. People tend to get comfortable with their portal, and tend not to change it.
I've got a bunch of tutorials on JSR168 portlet development at my website (Check out my signature links) Please check them out. They might help you get more comfortable thinking in a portlet mindset.
Heba has a very good point. It is fairly easy to have a class extend GenericPortlet and work as the controller in an MVC framework. Depending upon the PortletRequest coming in, the Portlet can forward to the appropriate JSP.