aspose file tools*
The moose likes JSP and the fly likes Conditionally load a java script file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Conditionally load a java script file" Watch "Conditionally load a java script file" New topic
Author

Conditionally load a java script file

PradeepPillai Pradeep
Ranch Hand

Joined: Nov 15, 2005
Posts: 184
We have a javascript file called "sitestat.js". We have it included in many jsp files that are reusable and we construct other main jsp files using these reusable jsps. The problem is that as a result of including these reusable jsps in other jsps, we ended up including "sitestat.js" multiple times in a jsp. Is there any way to load a jsp file conditionally only if it is not loaded already?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

Sounds like you need better organization for your JSP files. But as I doubt you;'d take that advice, you can set a scoped variable in the request when you include the script file and check it later to see of you need to include the file again. The <c:set> and <c:if> JSTL tags can be used for this. In fact, you can even write a custom tag to handle all of that for you in one place.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Conditionally load a java script file