I am working on an assignment where I need to display a right side panel on a jsp using tag handler class. To display that right side panel I would just need to put a custom tag in the parent jsp and everything else will be taken care of by tag handler.

the problem I am facing is,if I include scripts that are needed to display the right side panel on the screen in the parent jsp(in which the custom tag is put) and the tag handler would just take care of right side panel display, then it works fine. However, when I am trying to get scripts loaded using tag handler itself, it blows off.

Now I want to not to put scripts related to right side panel in parent jsp, instead, the sripts should be loaded at runtime where these scripts would be provided to jsp through tag handler itself.So, the tag hadler would do two things now...1. To load and provide the scripts needed by right side panel and ...2. To provide the structure and data of right side panel to be displayed on the screen.

Instead of searching how to load JS in a tag I would use some templating engine - e.g. tiles. This template engine will allow You to divide Your main page into separate pieces. This pieces will be plain jsp sites - independent of themselves. You can place the JS code on one of the sites the alltogether will be presenting the whole view.