Ganesh Gore wrote:In such case the best option is to write some code in other JSPs and include them in your main JSP. And inlcude them using <jsp:include> and not <@ include>.
NO, this is not the best option. See Bear's comment.
You should have
no Java code (or a little as possible if you just can't get away with none) in your JSPs. JSPs are to be used to render the HTML response that the browser will present to the user. They should not have any logic other than that related to displaying things to the user. Examples of acceptable logic in JSPs: looping through collections of information to display in a tabular form, conditionally making form fields visible or hidden when user first brings up a page, controlling which options are included in a select element based on the current user's security credentials. Examples of code that you should
NOT have in a JSP: accessing a database directly, calling web services directly, logic that implements core business rules, logic that controls flow of execution and information on the server side.
The appropriate use of "include" in a JSP is to facilitate reuse of certain display sections such as headers, navigation menus, footers, and the like.