• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Directory Structure JSP & JS

 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic