Solved

JSP Parsing Script tag

Posted on 2006-06-28
5
1,003 Views
Last Modified: 2012-05-05
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.
0
Comment
Question by:ka7ana
  • 2
5 Comments
 
LVL 3

Assisted Solution

by:runa_paathak
runa_paathak earned 50 total points
ID: 17000280
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
 
LVL 35

Accepted Solution

by:
TimYates earned 50 total points
ID: 17000285
Try putting a comment in the tag:

    <script language="javascript" src="..."><!-- my cool script --></script>
0
 
LVL 3

Expert Comment

by:runa_paathak
ID: 17000289
Anyway, your content break problem could be due to some other reason. Browsers can actually recognise empty tags like <tag/> actually.
0
 

Author Comment

by:ka7ana
ID: 17144502
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
squirrelPlay java challenge 40 157
Can't access image with tomcat/html 6 96
maven set up 2 128
equalIsNot  challenge 43 134
We need a new way to communicate time sensitive or critical info.   The best part of my role at xMatters is visiting our clients all over the world to learn about how they operate their businesses, share insights that xMatters has gleaned across…
An analysis of the phishing scam that has been affecting Google users, along with steps to take for protection, as well as what to do if you receive one of the emails.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now