Solved

JSP Parsing Script tag

Posted on 2006-06-28
5
991 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Hyena v12.2 is now available for downloading and is available in English, French, German and Spanish versions.
In this article, I will show you HOW TO: Perform a Physical to Virtual (P2V) Conversion the easy way from a computer backup (image).
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the fileā€¦

760 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

19 Experts available now in Live!

Get 1:1 Help Now