JSP Parsing Script tag

Hello experts,

I'm writing a webapp using JSP and the Spring Framework. One of my pages makes use of a substantial amount of JavaScript code, which I'm trying to include as an external file using the <script> tag, i.e.

<script language="javascript" src="..."></script>

Unfortunately, this is being parsed and sent to the browser as:

<script language="javascript" src="..." />

Which breaks the content of the page (as the browser is still expecting the closing </script> tag). Does any one have a solution to get round this?

Many thanks,

Darren.
ka7anaAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
TimYatesConnect With a Mentor Commented:
Try putting a comment in the tag:

    <script language="javascript" src="..."><!-- my cool script --></script>
0
 
runa_paathakConnect With a Mentor Commented:
There should be a more elegant solution, but this should also work. Change the line

<script language="javascript" src="..."></script>

to

<script language="javascript" src="...">var i = 0; </script>

:)
0
 
runa_paathakCommented:
Anyway, your content break problem could be due to some other reason. Browsers can actually recognise empty tags like <tag/> actually.
0
 
ka7anaAuthor Commented:
Ah, sorry - totally forgot to award the points on this question. I did follow a similar method to those posted above, and so I'll split the points evenly between runa_paathak and TimYates. Additionally, I came across this method, which I have started using of late:

<![CDATA[
<script language="javascript" src="myscriptpath.js"></script>
]]>
0
All Courses

From novice to tech pro — start learning today.