Making a web app which allows the user to view the server desktop
To allow the user to interact with the desktop in real-time, you need to run the application in the users web browser. Interaction with a webserver would just be too slow to do anything meaningful. I do not know about any way to execute Python in a web browser, so I would rule it out. Some of your options for client-sided code execution are:

Javascript (the recent addition of Canvas and WebSocket made it suitable for this kind of problem)
Java Applets (felt out of favor recently due to security problems)
ActiveX (IE- and Windows only, very rarely used in a public context nowadays)
Flash (a popular but dying technology)
I did a pretty fair bit of scouring, yet could not find anything useful which answers my questions. Either that or I am asking the wrong questions.
I am trying to make a web application which gives a user a graphical view of the server desktop. I have understood that somewhere in here X engine has to be invoked and I have also understood that this is not something that php can accomplish primarily because its a language which processes before sending requests, please correct me if I am wrong in this regard.
You may say that what I am trying to accomplish is something akin to what teamviewer does only on the web. My dilemma is whether I should be using python or java for this task, both would be pretty apt for the task, but which one would be better? 
Please give your suggestions