File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Referencing Javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Referencing Javascript" Watch "Referencing Javascript" New topic

Referencing Javascript

Phil Haigh

Joined: Jan 19, 2006
Posts: 26

My Struts application has all its JSP pages stored under WEB-INF. I want to reference a javascript file inside a JSP file and I'm struggling to get it to work.

At the moment my javascript is in a 'javascript' directory that is at the same level as WEB-INF (under the top level of the web application structure), the action that results in the JSP being sent to the client is of the format "/forms/" and the script tag looks like this: <script language="javascript" src="javascript/form-rules.js"></script>

The page loads but the JavaScript doesn't work. If I move the javascript code into the JSP everything works fine.

All suggestions appreciated,


dnyan ginde
Ranch Hand

Joined: Jan 17, 2006
Posts: 68
I think the problem is that the location of the javascript is not being found. Put tag after <html:html> tag in ur jsp and try. I think this should work.
It is sorta covered in the JavaRanch Style Guide.
subject: Referencing Javascript
It's not a secret anymore!