tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shapira, Yoav" <>
Subject RE: Newbie Alert! - including a a JavaScript src file in a servlet
Date Thu, 16 May 2002 17:17:28 GMT
Howdy, and welcome to the list ;)

You should put the JavaScript file NOT in the WEB-INF directory.  Put it
under your web application (ROOT in your example).  Stuff under WEB-INF
is not accessible to the browser.  See the Servlet spec from Sun on how
to organize files under your web application.

So in your case: the servlet is fine where it is.  Move the .js file to
/ROOT/code_lib.js.  Include it as
<script type="text/javascript" language="JavaScript" src="/code_lib.js">

And that should take care of the problem.

Yoav Shapira

>-----Original Message-----
>From: []
>Sent: Thursday, May 16, 2002 1:13 PM
>Subject: Newbie Alert! - including a a JavaScript src file in a servlet
>Hopefully this is the correct forum to post a question such as this:
>I have a servlet in which I would like to write out some script tags to
>indlude a JavaScript src file in the outputted HTML.
>My application is in /ROOT/WEB-INF/class/code_lib, the .js file
>(code_lib.js) I would like to include is within this directory as well,
>I am trying to include it this way:
>out.println("<script language=\"JavaScript\" src=\"code_lib.js\">");
>So, in the resulting html we have "<html><head><script langauge =
>"JavaScript" src="code_lib.js"></script></head>...
>When I run the servlet the generated page cannot find the .js file.
>should I put files I want to include in the outputted html (such as .js
>.css files)? Can this even be done?
>To unsubscribe, e-mail:   <mailto:tomcat-user-
>For additional commands, e-mail: <mailto:tomcat-user-

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message