In my JSP document, I have the following script element defined. <script type='text/javascript' src='/include/scripts/menu- row.js'> </script>
Yet, when I load the page in a browser and view the page source I get the following. <script type='text/javascript' src='/include/scripts/menu- row.js'/>
Since the script element does not support the inline syntax, everything after this element is interpreted as a script instead of how it should be.
I am using Tomcat 6.0.18
Here is the full JSP document. ---------- <?xml version="1.0" encoding="UTF-8" ?>
<html> <head> <script type='text/javascript' src='/include/scripts/menu- row.js'> </script> </head> <body> Random text </body> </html> </jsp:root> ----------
This is the output when I view the page source in a browser. ---------- <html> <head> <script src="/include/scripts/menu-row.js" type="text/ javascript"/> </head> <body> Random text </body> </html> ----------
Does anyone have any idea where this conversion from the <script></ script> syntax to the <script/> syntax is being done and why?
jsguru72 wrote: > In my JSP document, I have the following script element defined. > <script type='text/javascript' src='/include/scripts/menu- > row.js'> </script>
> Yet, when I load the page in a browser and view the page source I get > the following. > <script type='text/javascript' src='/include/scripts/menu- > row.js'/>
> Since the script element does not support the inline syntax, > everything after this element is interpreted as a script instead of > how it should be.
> I am using Tomcat 6.0.18
> Here is the full JSP document. > ---------- > <?xml version="1.0" encoding="UTF-8" ?>
> This is the output when I view the page source in a browser. > ---------- > <html> > <head> > <script src="/include/scripts/menu-row.js" type="text/ > javascript"/> > </head> > <body> > Random text > </body> > </html> > ----------
> Does anyone have any idea where this conversion from the <script></ > script> syntax to the <script/> syntax is being done and why?
> Thanks
It's Tomcat apparently because of your jsp:root declaration.
I am still not clear as to what is actually doing this.
I have done some additional testing and found that this only happens when using a JSP document (XML). If I do this in a plain JSP page or in an HTML page, then it all works fine and the script element is sent to the browser as I entered it.
Should I not be using a jsp:root declaration? All of the documentation I see shows that as the root element.
Any idea what in Tomcat would be doing this? Do I need to edit some configuration?
"I think if you know what you believe, it makes it a lot easier to answer questions. I can't answer your question."
--- Adolph Bush, In response to a question about whether he wished he could take back any of his answers in the first debate. Reynoldsburg, Ohio, Oct. 4, 2000 (Thanks to Peter Feld.)
jsguru72 wrote: > I am still not clear as to what is actually doing this.
> I have done some additional testing and found that this only happens > when using a JSP document (XML). If I do this in a plain JSP page or > in an HTML page, then it all works fine and the script element is sent > to the browser as I entered it.
> Should I not be using a jsp:root declaration? All of the > documentation I see shows that as the root element.
> Any idea what in Tomcat would be doing this? Do I need to edit some > configuration?
> I am drawing a blank so guidance is appreciated.
> Thanks.
Like Lew, I'm no expert in this area.
You're providing an empty js declaration and the jsp:root element causes the container to rewrite it. If you put code within the js declaration, it does not change it:
Long story short, it appears that you'll need to make your js declaration compliant, a good place to start learning how is here (jsp:root shows about 3/4 of the way down):
I looked through that tutorial and I am trying to see where it says the jsp:root element is rewriting the empty script element.
Regardless, your comment about it being an empty declaration prompted me to insert a random character to the script element, I added a hyphen. So now my script element has this. <script type='text/javascript' src='/include/scripts/menu-row.js'> - </ script>
It works perfectly. I had previously thought it was something along these lines and just put a space between the tags, but I guess I needed to have a non-whitespace character.
I obviously have a few things to learn about JSP documents. I will read the tutorial you listed more thoroughly and see what other information I can dig up.