I have an index.jsp file and uploaded it into the www folder of WAMP (apache). When I try to run it via localhost, it only displays the code. Can you please explain me how to run the index.jsp file on my WAMP server?
JSP-files are Java Server Pages files. You need servlet container to run them (e.g. tomcat).
Nowadays it is quite uncommon to write web application just using jsp. More common way is that jsp is used as view technology with some application framework. So I'd make sure the jsp-file you have is a complete application instead of some page in some bigger application.
Note that this very highly simplified answer, more from wikipedia.