• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

How to access a java script file in my jsp while rnning through eclipse

 
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i wanted to know which path should i place my javascript file so that my jsp could access it ??
FireFox gave me this error
[07:03:42.319] GET http://localhost:8080/Grid_Sample/editablegrid-1.0.11.js [HTTP/1.1 404 Not Found 2ms]
I tried placing the.js file rite next to my jsp but still i got this error ?? Any suggestions on what the path should be ??
I am using eclipse and i also run and test my jsp files through eclipse
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What kind of Eclipse project did you create? A Dynamic Web Web Application Project? If so, place the .js file in the WebContent folder.
 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah its a dynamic webproject and I am using Tomcat.
The jsp file is in
d:\users\Adam\workspace\Grid_Test\Webcontent\result.jsp

I placed the javascript file called editablegrid-1.0.11.js next to result.jsp ie
d:\users\Adam\workspace\Grid_Test\Webcontent\editablegrid-1.0.11.js

and my jsp file is calling the javascrip file using


but still firefox gives me



any ideas why ??? same thing with my .css files ?? I am a bit confused about the location.. Any suggestion would be appreciated..

 
Adam Zedan
Ranch Hand
Posts: 124
C++ Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay i did a little experimentation and i came up with the following. If i place the file directly in the webcontent folder using windows explorer it doesnt work.
But if i copy the file and goto the Javascript Resources section of eclipse and paste it there then eclipse pastes a copy of the file in the webcontent folder itself and at the same time imports a list of all the functions in the file.
Now is there any way to just specify a path instead of pasting all the time and how would i link css files ??
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By placing the file there in Explorer, Eclipse was not aware of its existence. Therefore, it never copied the .js file over to the deployed WAR. You need to inform Eclipse that the file is there. You can do it either the way you said (copy into Eclipse) or after copying via Explorer, hit F5 to refresh your project.

Moral of the story: if the file does not show up in the package view in Eclipse, the file does not exist within your project!

Your files, including CSS, must all be in the WebContent directory. Actually, they really just need to be in the deployed WAR file. So if you don't want to copy those files into your project, you should look into using a build tool such as Ant or Maven to build the WAR.
 
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic