I would like to give a little idea of who exactly is Moshiach ben Yosef, and I would also like to weave in some strands of the dvar Torah that I said in my Parsha Podcast on Vayeshev.
Firstly, let us understand why we need two different Moshiachs.
The Moshiach we've all heard of is Moshiach ben Dovid, who we mention in our tefilos.
The lesser known is Moshiach ben Yosef. His job is the physical aspects of Klal Yisrael. He brings the Jewish people back to Eretz Yisrael (kibutz galuyos). He takes part in rebuilding the land of Israel. He builds the physical structure of the Beis Hamikdash. He is also privy to the secrets of the Torah (חכמת הנסתר). His job is to destroy Esav (see Rashi on Genesis 30:25). His power is the rectification of יסוד - the אות ברית קודש. He has full dominion over his physical desires - he rises above them and merits miracles. His power is also the power of Emunah/Bitachon - absolute trust in Hashem which also corresponds to יסוד. This also merits miracles, as per my earlier post "Bringing Miracles of Redemption."
The role of Moshiach ben Dovid on the other hand, is to bring the Shechina into the physical structures that Moshiach ben Yosef builds. Moshiach ben Dovid brings the Shechina into the Beis Hamikdash, into the Land of Israel, into the Jewish people. He is the מלך - which means that he reveals מלכות which is equal to שכינה.
This is why we say first ולירושלים עירך ברחמים תשוב - To Jerusalem your city return with mercy, before we even mention Moshiach ben Dovid. We say ובנה אותה בקרוב בימינו בנין עולם - rebuild it soon in our days an eternal building - this is reference to Moshiach ben Dovid. Then we say וכסא דוד עבדך מהרה לתוכה תכין - and the seat of David your servant quickly prepare in its midst. Here we see that it is a two step process, starting with the job of Moshiach ben Yosef and culminating with the job of Moshiach ben Dovid.
According to the Gemara in Succah, Moshiach ben Yosef is destined to die. The Gr'a holds that this is לאו דוקא, and says that in fact, the length of the gallus has already atoned for whatever would have necessitated his death. His שיטה is עוד יוסף חי - Moshiach ben Yosef will yet live.
Another interesting point which I have seen in more than one place is that besides for there being a single human being named Moshiach ben Yosef and Moshiach ben Dovid, there is a force within the Jewish people that corresponds to their role. This is actually similar to how you may have specialized cells in your body that perform a certain specific function, say the cells in your eyes. Nevertheless, every single cell in your body contains the same DNA, with that very information that makes those eye cells specialized. The only difference is that the other cells, say in your hand, do not express and bring out that specialized nature to its full expression. Nevertheless, that power exists everywhere within a person.
Thus, every Jew can donate to Moshiach ben Yosef's role, for there is a small piece of Moshiach ben Yosef in every Jew. In fact, people who work for Nefesh B'nefesh, as an example, are actually fulfilling one of the roles of Moshiach ben Yosef - kibbutz galuyos. When we bring spirituality into our lives or the lives of others, we are activating the Moshiach ben Dovid in each of us. This brings us a step closer to Geulah and effectively lightens the load of each of the Moshiachs.
Returning to Yosef, we see that his job was to take care of the physical welfare of the Jewish people. This was expressed in his dream with the stalks of produce, and later in his role of providing for Egypt and more specifically the seventy souls that descended to Egypt with Yakov. His role as the knower of the secrets of the Torah is also mentioned in numerous sources, and is hinted to by his name צפנת פענח - the revealer of secrets. It is also hinted to in the reference בן זקנים - the gematria of the bold is 207 which is the same as the word רז - secret (בעל הטורים).
Yosef was the master of תיקון הברית as he displayed in his difficult encounter with the wife of Potifar. He was also the quintessential בעל אמונה. He had the ultimate faith in Hashem and throughout the story of his trials stood steadfast in his faith in Hashem, never questioning, only constantly moving forward and staying strong. He himself constantly reassures his brothers that he bears them no ill will, but rather from the onset it was the will of Hashem that Yosef be sent to Mitzrayim.
Yehoshua bin Nun was from the tribe of Efraim (son of Yosef) and he fulfilled the role of Moshiach ben Yosef in his time - conquering the land of Israel and dividing it amongst the Jewish people.
Very interestingly, according to the site http://keitzmeguleh.blogspot.com, the current year (5769) corresponds to the first year of Yehoshua's conquest. Exactly what this means and how this will play itself out remains to be seen. (For more on that, please see his post Geulat Mitzraim to Yemot HaMoshiach)
Last point I would like to make is the pshat I said in my parsha podcast about Yosef's second dream. It is clear from the psukim that the second dream was a different dream (חלום אחר) as opposed to Paroh's dream which the Torah says ויחלום שנית - he dreamed a second time. Whereas Paroh had a repetition implying the dream would soon materialize, Yosef's second dream was a totally different dream with a totally different message.
The key to the message of the second dream is that the sun, moon and stars were bowing down to Yosef. The almost silly sounding question is, what do stars look like when they bow down?
The answer is that the prophets tell us that before Moshiach comes, the sun, the moon and the stars go out (יואל ד:ט"ו). They are extinguished, and then we are told that we no longer will be provided with light from the sun, but rather Hashem Himself will be our light. The message underlying this concept is that whereas until Moshiach Hashem directed the world through the מזלות - the constellations and the heavenly bodies, when Moshiach comes, Hashem Himself will be the One Who directly is involved in the world, with no more intermediaries. This is why the sun, moon and stars go out, to signify that they are no longer the conduits, but rather Hashem will now be leading us directly.
The concept of bowing - השתחוויה - is that one shows that he totally nullifies himself in the face of the one he is bowing to. This is what was happening in Yosef's dream. He saw of vision of the ultimate future when the sun, moon and stars would 'bow,' as it were, to Yosef's emunah. This emunah would bring about the days of Moshiach where Hashem himself would deal directly with the world. This emunah - which by definition taps into the concept that Hashem is directly involved in our lives - was what Yosef represented, and to this they bowed - showed their lack of existence - and were extinguished. The eleven stars represent the fact that all of the Jewish people will bow to Moshiach ben Yosef - that is, we will learn from him the power of Emunah and absolute trust in Hashem that will bring about Hashem's full display of His direct involvement in our lives.
May we merit that day soon.