I am having one compare() method in a.jsp. I am including b.jsp in a.jsp using <jsp:include page="b.jsp" /> here i have to pass Compare() method to b.jsp.
You can't. These days it's considered poor form to write methods directly to your JSPs. It's better to put them in plain old Java classes which can be called from any point within your application.