I want to invoke an XPage from a rest client e.g http://myserver.com/myDB/myApp.nsf/mypage.xsp?attr=first
and have the XPage mypage.xsp to print the attr value.
var value1 = context.getUrlParameter("attr");
print(value1);
Is it possible?
Yes. Google "XAgents", there are plenty of resources about how to call an XPage and return non-XPage code.
Also, make sure you set viewState property of the XPage to "nostate", because there's no point storing a component tree server-side for something that can't be partially refreshed.