The following is only relevant to your second example, its not possible to share state between pages based on different controllers (as per ScottW's answer).
Sharing State between Pages with the Same Controller. I've just tried this, which I am sure I've seen work before and is documented, but I'm getting a corrupted page back from Salesforce as result of the redirect. I've logged it as an answer just to illustrate what I've tried, as I thought it might have worked and still feel it should, perhaps a Salesforce bug?
<!-- messagepage1 -->
<apex:page controller="MessagePageController" action="{!doAction}">
</apex:page>
<!-- messagepage2 -->
<apex:page controller="MessagePageController">
<apex:pageMessages />
</apex:page>
public with sharing class MessagePageController {
public PageReference doAction()
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Test message'));
return Page.messagepage2;
}
}
As per the docs...
If set to false, the redirect is a server-side forward that preserves the view state if and only if the target page uses the same controller and contains the proper subset of extensions used by the source page.
So I also tried...
public PageReference doAction()
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Test message'));
PageReference page2 = Page.messagepage2;
page2.setRedirect(false);
return page2;
}
Without success either, very strange. So it may look like the answer is to pass the information as a parameter as per this question Show Apex message at another page