Quoting Koon Yue Lam <[EMAIL PROTECTED]>: > ok, it is really strange that I need to specify full path > "/myApp/js/myJS.js" > rather then just > "js/myJS.js" > > but if I use full path , everything works fine > > I am using Tomcat 5.028 with Struts 1.1 >
The server does not matter. The application framework does not matter. What matters is the URL you are accessing. What is the URL in the location field of your browser? Using relative "js/myJS.js" means that the URL you are accessing must be at the root of your context path (be it "/" or "/myApp"). For instance, if your "js" directory is at the root of your context, then the following URL would allow the relative path to work... http://localhost:8080/myApp/hello.do Because "hello.do" is accessed from the root of the context, the relative path to the .js file would be... http://localhost:8080/myApp/js/myJS.js Note that this is identical to specifying the absolute path of "/myApp/js/myJS.js". However, the relative path will stop working if your URL goes one directory into your app while the absolutely defined one will continue to work... http://localhost:8080/myApp/somdir/hello.do now your relatively defined path to the .js file would resolve to... http://localhost:8080/myApp/somedir/js/myJS.js If you want to not have to worry about stuff like this, use an absolute path. Don't hardcode the name of your context, though. Use... <script src="<%=request.getContextPath()%>/js/myJS.js" type="text/javascript"></script> Struts has some JSP taglibs to help out with this so you don't necessarily have to use a scriptlet like this everywhere, so look into that, but this gives you the gist of what you need to do to make sure your web resources can be accessed no matter the path of the current URL. Jake > thanks for all the help > > Regards > > > On Wed, 29 Dec 2004 01:08:31 +0800, Koon Yue Lam <[EMAIL PROTECTED]> wrote: > > Thanks for all the reply, I will try it out tonight and let u all know > > the result ^^ > > > > Regards > > > > > > On Tue, 28 Dec 2004 18:52:37 +0200 (EET), [EMAIL PROTECTED] <[EMAIL > > PROTECTED]> > wrote: > > > > > > Laba diena. > > > > > > Dėkojame, kad mums parašėte. > > > > > > Jūsų atsiųsta žinutė išsaugota mūsų duomenų bazėje. > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]