wood burning stoves 2.0*
The moose likes Spring and the fly likes Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem" Watch "Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem" New topic
Author

Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem

K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
Folks- I'm stuck with this simple thing. I have a Hello World type Spring MVC based web app and I wanted to play with JQuery, but for the life of me, can't make it work, my jsp just won't 'see' the following:



in my jsp:





I have a feeling something is wrong with the WAR file structure, or do I have to do something Spring related to serve static content?

+root-of-war
WEB-INF/
---jsp/
------myjsp.jsp (this is where i access jquery)
js/
---jquery-1.5.2.js

Please help, I'm stuck since yesterday.
Thanks in advance.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

The URL is suspect. It should begin with the context path of the web app. What you have will only work if the web app happens to be the root context.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
K Mansoor
Ranch Hand

Joined: Jan 10, 2006
Posts: 52
I changed the URL to include the context:

This resulted in the following error:

changed the URL to:

added

to mycontext-servlet.xml

changed dir structure to:

+root
resources/
---js/
------jquery-1.5.2.js

And it's working!

Thank you so much for putting me on the right path. I could never have figured it out.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65



It'd also be best not to hardcode the context path. You can use:to grab it programmatically.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Thought I knew WAR structure: Spring MVC/JQuery (simple) path problem
 
Similar Threads
Javascript and the DispatcherServlet
%@ include and Javascript
lightbox Question
%@ include and Javascript
Windows XP Popup blocking