Solved

JSP Parsing Script tag

Posted on 2006-06-28
5
1,033 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The goal of this blog is: - To define the incident management process - To go over the key elements of an incident management system - To look into incident alert management tools that integrate with ConnectWise.
Invest in your employees with these five simple steps to improve employee engagement and retention.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decadeā€¦
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

739 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