Including JS files (jQuery) in JSPX files

I am creating a dynamic web project in Eclipse (almost from scratch) and I created a JSPX file in which I put

<head>... <script type="text/javascript" src="route/to/scripts/jquery.js"></script> <script type="text/javascript" src="route/to/scripts/jquery.ui.js"></script> <script type="text/javascript" src="route/to/scripts/something.js"></script> </head> 

I intend to use the jQuery UI sortable , and I found out that using JSPX only the first scripts are loaded in Firefox and IE (while it works in opera ...). If I use simple JSP, be it HTML XHTML, it loads all the JS files.

Is there a way to include all JS files successfully without using

 <script> <jsp:include ...> </script> 

which should i know about? (because it loads the INTO script in the final (X) HTML)

EDIT: Just think ... why does Opera read xhtml correctly until FF and IE were able to read the <script> tags? Could this be a mistake?

+7
source share
1 answer

JSPX has fancy behavior that automatically drops tags without a body. Effectively

 <script type="text/javascript" src="route/to/scripts/jquery.js"></script> <script type="text/javascript" src="route/to/scripts/jquery.ui.js"></script> <script type="text/javascript" src="route/to/scripts/something.js"></script> 

will end in the browser as

 <script type="text/javascript" src="route/to/scripts/jquery.js" /> <script type="text/javascript" src="route/to/scripts/jquery.ui.js" /> <script type="text/javascript" src="route/to/scripts/something.js" /> 

which is invalid <script> syntax (right page in browser and view View Source to see it yourself). The behavior of the browser is not defined.

You can get around this by putting <jsp:text /> between tags

 <script type="text/javascript" src="route/to/scripts/jquery.js"><jsp:text /></script> <script type="text/javascript" src="route/to/scripts/jquery.ui.js"><jsp:text /></script> <script type="text/javascript" src="route/to/scripts/something.js"><jsp:text /></script> 
+9
source

All Articles