"Now when Joshua was near Jericho, he looked up and saw a man standing in front of him with a drawn sword in his hand. Joshua went up to him and asked, 'Are you for us or for our enemies?'" NIV translation
Joshua went out to take a look at Jericho as he was going to be leading Israel into battle against them. When he got there, he was met by a man with a drawn sword and so he asked whose side the man was on.
"'Neither,' he replied, 'but as commander of the army of the Lord I have now come.' Then Joshua fell facedown to the ground in reverence, and asked him, 'What message does my Lord have for his servant?'" NIV translation
The man introduces himself as the commander of the army of the Lord. This is clearly Jesus because, when Joshua fell down, the man did not warn him about doing so. When an angel has that happen, they are quick to tell the man to get up because they are unworthy of worship.
"The commander of the Lord's army replied, 'Take off your sandals, for the place where you are standing is holy.' And Joshua did so." NIV translation
Joshua had asked for a message but the only thing he got was that the place where he was standing was holy. It was holy because it was Jesus standing there with him. So, why was Jesus there and why did He say that He was on neither side? Jesus was there to remind Joshua that it is not about him but about God. God had elevated him in the eyes of Israel but he had to remember that he was still a subject of the King of Kings. He was going to take Jericho but not because of any plan that Joshua had but because it was in God's plan for His people. Many times we, as Christians, will get wrapped up in our plans and forget that it is only God's will that matters because He knows best. We are to be conformed to His will not trying to conform His will to our plans. There is freedom and a whole lot less stress when we realize that we do not have to come up with plans. Instead, we can trust in the plans of God. If we listen to the prompting of the Holy Spirit, we will be led into His perfect will for any situation.