Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tomcat interprets other things that JSP tags

Status
Not open for further replies.

Gunnar99

Programmer
Apr 22, 2005
9
SE
I include these 3 files in a JSP page;
<script language="JavaScript" src="tree.js"></script>
<script language="JavaScript" src="tree_items.js"></script>
<script language="JavaScript" src="tree_tpl.js"></script>

But then I got the following error in the Tomcat consol;
javax.servlet.ServletException: Wrapper cannot find servlet class tree_tpl.js or a class it depends on

It's the same for all 3 files.

I will have related errors if I use JSP include instead.

For some reason Tomcat seems to interpret my Javascript code as Java code.

Why?

Shouldn't just JSP tags be translated and everything else just printed as it is?

Thankful for help.

/Best Regards, Mats
 
Can you post a small test case JSP that shows this behaviour ?

--------------------------------------------------
Free Database Connection Pooling Software
 
I changed and tried with out.println for the Javascript statements.
But I still get Tomcat errors. Strange?
And it doesn't happens anything in my browser.
But if I copy the browser source code to a html file and run this html file - everything works fine.
Shouldn't the browser treat a html file and jsp file in the same way?

Here is my jsp file with the out.println;

<html>
<head>
<title>JavaScript Tree Menu</title>
<meta name="description" content="Free Cross Browser Javascript DHTML Tree Menu Navigation">
<meta name="keywords" content="JavaScript tree menu, DHTML tree menu, client side tree menu, table of contents, site map, web authoring, scripting, freeware, download, shareware, free software, DHTML, Free Tree Menu, site, navigation, html, web, netscape, explorer, IE, opera, DOM, control, cross browser, support, frames, target, download">
<meta name="robots" content="index,follow">
<style>
a, A:link, a:visited, a:active, A:hover
{color: #000000; text-decoration: none; font-family: Tahoma, Verdana; font-size: 12px}
</style>

</head>

<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0" marginheight="0" marginwidth="0" bgcolor="white">
<%
String treeItems = (String)request.getAttribute("treeItems");
%>
<% out.println("<script language='JavaScript' src='tree.js'></script>"); %>
<% out.println("<script language='JavaScript' src='tree_items.js'></script>"); %>
<% out.println("<script language='JavaScript' src='tree_tpl.js'></script>"); %>

<table cellpadding="5" cellspacing="0" cellpadding="10" border="0" width="100%">
<tr>
<td>
<script language="JavaScript">
<!--//
new tree (TREE_ITEMS, TREE_TPL);
//-->
</script>
</td>

</tr>
</table>

</body>
</html>

/Mats

 
That is bizaar.
So normally the js tags are in the <head> section, and you have this named as "somefile.jsp" ?

--------------------------------------------------
Free Database Connection Pooling Software
 
Yes.
The filename is tree.jsp and the tags are in the head.
It's OK if I write
<% out.println("<language='JavaScript' src='tree_tpl.js'></script>"); %>
So it seems that it's the word "script" that bother Tomcat.
I'm running a Servlet that makes a forward to this JSP.

/Mats
 
One more thing.
It's OK just to JSP include the files.

But not to add this;
<script language="JavaScript">
<!--//
new tree (TREE_ITEMS, TREE_TPL);
//-->
</script>

Tomcat seems to belive this is a Java statement.

And it doesn't help to write like this;
<script language="JavaScript">
<!--//
<%out.println("new tree (TREE_ITEMS, TREE_TPL);");%>
//-->
</script>

/Mats
 
I tried another thing;
I printed the HTML direct from my servlet.
But it was the same thing!
I thought that I was printing direct towards the socket when I
printed to the PrintWriter.
But Tomcat seems to be analyze these code too.
Strange!!!!!!!!!!

/Mats
 
I used Tomcat 5.5.4 and when I changed 5.0.25 so has the consol errors disappered.
But nothing happens in the browser.
But when I display the source code and copy it to a HTML file everything works fine.
I don't really understand this - shouldn't just Tomcat translate things and send it back to the browser and the browser will react on the data exactly the same as for a HTML file?
Is the problem that I use DHTML?

/Mats
 
If I use JSP include it works almost fine.
And Tocat version 5.5.9 works fine also.
But one thing that doesn't work is the icons in the menu structure.

They are specified with image.src(filepath).
The JSP files are located under the application map in Tomcat and the icons are in a map called icons in the application map. So image.src(icons/imagename.gif) is used as the filepath. And this works fine if I run the page as a HTML file. But it doesn't work for a JSP file coming from Tomcat.
I have tried different variants of the filepath; an absolute filepath from C: and to have the the imageicons in the same map as the JSP file and just use image(imagename.gif). But it doesn't work. Anyone who has an idea?

/Mats
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top