Bharadwaj Adepu wrote:
How come this would be a workaround again? Here we'll include the common JSP and replacing around 25 lines of code, that too in all 10 to 15 JSPs.
suppose around 25 lines of code lies continuesly then you can use common jsp . As you mentioned above if code breakes like here and there then using common jsp (passing some html text from one jsp to another) is looks bad. is n't it?
As you have said you wanted to move some common repeating JSP code logic to a seperate JSP and call this new JSP in all other places, it is not just the view logic that you have in JSP, you will have business logic that is hard bound to your JSP. So even if you move this logic to a seperate JSP there is no way to reuse this business logic. There would be scenarios wherein it would be better off if you encapsulate the view form the business logic so that there would be more reusability of the business logic when it is commonly coded.
Ofcourse as said by others, you could cretae your own tag libraries or move the logic to a seperate Servlet.
An even better solution would be for you to move to Struts framework, wherein you would have better control of this scenario, but again it all depends on the timeline you are looking at to acheive this. It is always better to go for a framework that would address your problem, wherein you could get more than what you ask for, as these frameworks are designed by people who had already faced similar kind of issues.
Could you explain why Struts would not solve this issue.
I mentioned Struts coz not only to solve the current problem what Bharadwaj has mentioned, but it would be of more help on a long run wherein the application would grow up to be off 100 or more JSP's, wherein as I mentioned, going for Struts would be fruitful.
As sugested by others, in my past experience as a programmer, I have worked in custom tag libraries, Servlets and Struts as well. It all pivots around the same, MVC.
But, I rather found Struts to be of more use as it had much clear demarcation of the layers.
Many thanks for replying to my problem.
Here there is one more thing that i have to mention, the architecture we are using is not MVC, from the JSP itself we are calling the Bean using <jsp:useBean /> , there is no controller like servlets.