Solved

JSP Parsing Script tag

Posted on 2006-06-28
5
1,010 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maven project import to eclipse problems 13 104
doubleChar java challenge 7 106
struts spring hibernate example 12 121
servlet example 17 28
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
How do we balance the user experience (UX) with reasonable security measures? It can be done, if you keep these fundamentals in mind.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

10 Experts available now in Live!

Get 1:1 Help Now