aspose file tools*
The moose likes JSP and the fly likes Directory Structure JSP & JS Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Directory Structure JSP & JS" Watch "Directory Structure JSP & JS" New topic
Author

Directory Structure JSP & JS

Jennifer Moran
Ranch Hand

Joined: Oct 21, 2002
Posts: 60
I am going to go insane. I have a web project using JSP and JQuery (which are included js files in the JSP pages). The only way I can get it to work is if I move ALL files to the same level as the WEB-INF folder. When I put them in a folder structure (mind you folders are ALSO the same level as the WEB-INF just in different folders) I keep getting the message JQuery is not defined. I have moved these files, folders all over the place and cannot get it to work except in that one scenario. Can someone PLEASE help me!!!

Here is the default.jsp (BTW the default.css has no problem loading)


Directory structure is



Thanks,

Jennifer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Your URLs to the JavaScript files are page-relative. That is death in a web app.

Your URLs should be server relative, beginning with the context path of the web app. see the JSP FAQ for more details.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

P.S. Please be sure to use code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along to posts that are easier to read. Please read this for more information.

You can go back and change your post to add code tags by clicking the button on your post.
Jennifer Moran
Ranch Hand

Joined: Oct 21, 2002
Posts: 60
Thanks for the reply Bear.

I used the request.getContextPath and it looks like it is resolving correctly (see below from firebug console)



but I am still getting JQuery is not defined.

I also coded this javascript directly inside the <head> tag



and this for the <body> tag



and that works fine.

Any other thoughts would be greatly appreciated....

Jennifer
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60050
    
  65

Jennifer Moran wrote:but I am still getting JQuery is not defined.

Are you referencing JQuery or jQuery? Case counts.

<body onload="javascript:onLoad();">

If you are using jQuery, you should not be doing this. You should be using the document-ready handler and you should also be following Unobtrusive JavaScript and never embed script in HTML tags.

Your life will be happier.
Jennifer Moran
Ranch Hand

Joined: Oct 21, 2002
Posts: 60
The jQuery script is actually from the jqGrid plugin documentation found at

jqGrid

I am trying to do the tutorial and I just cut and paste the code from the above link.

Maybe the jQuery is a typo?? Is it defined somewhere?? How do I know, how can I track it down to see what it should be? I want to understand behind the code also.

I originally had the onLoad function coded in a file called test.js which I also tried to include and then call from the onload method in the body tag but then i was getting the additional error of 'onLoad() not defined'. Which makes me think for some reason it still isnt including the js files. Because when I coded it right in the head tags of the default page (previous post) it worked.

thanks,

jennifer
Jennifer Moran
Ranch Hand

Joined: Oct 21, 2002
Posts: 60
Okay I am almost too embarrassed to post this but my problem was my folder javascript had a typo in it. It's really enough to make me scream at the top of my lungs...stupid stupid stupid mistake......

Anyway, sorry for the waste of time, but I did learn the proper way to include my js files so I guess it wasn't a total waste
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Directory Structure JSP & JS
 
Similar Threads
Struts 2 Tiles
values are not populated in browser
JSON JQuery Grid Not getting value in JSP
JQuery not working in JSF 2.0
JSPF file can not be included in JSP file and gives error