Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8383835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:15:56+00:00 2026-06-09T17:15:56+00:00

I have a js file in the folder WebContent/resources/js/test.js. I am trying to include

  • 0

I have a js file in the folder WebContent/resources/js/test.js. I am trying to include the same file in a jsp. But the jsp file is unable to find the js file (404 error in browser console). I have gone throw couple of questions in SO:

Can SpringMVC be configured to process all requests, but exclude static content directories?

Browser can't access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP

STS Spring MVC: How to include a JS file in a JSP

But still not helping. Here goes my code:

In the application context, i am using the mvc:resource tag.

<mvc:resources mapping="/resources/**" location="/resources/" />

In my jsp

<script src="${contextPath}/resources/js/test.js" type="text/javascript"></script>

tried giving src value with

 <c:url> 

too.

my web.xml has

<servlet-mapping> 
<servlet-name>TestProject</servlet-name> 
<url-pattern>/</url-pattern>
</servlet-mapping>

Firebug says

The requested resource (/resources/js/test.js) is not available.

Any help would be appreciated.

UPDATE

The GET request URL in firebug is this

http://localhost:8080/TestProject/resources/js/test.js

Is it right??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:15:58+00:00Added an answer on June 9, 2026 at 5:15 pm

    You need to do

    <script src="<c:url value="/resources/js/test.js" />" type="text/javascript"></script>
    

    Spring is trying to find the resource from the container context root, rather than the app context root.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a file watch directory named FileWatch C:\Users\MyFolder\FileWatch\Test The FileWatch folder is the
I have a file called 34.php?session=2534464a39a2c97cb7113689726a4e52 in my /var/www/html folder but I can't view
I have html file in resources folder to load in uiwebview. I need to
My situation is simple. I have this in my program: File folder = new
I have a zip file containing a folder and inside the folder I have
I have a template file in a folder c:\template_folder. At runtime, I will create
I have a file in a different folder I want to rename in perl,
I have a file dk.po and dk.mo in folder lang in my webdir. How
I have a file called config.yml in my /config folder of my rails application.
I have a file named configuration.xml which resides in classes folder of my WEB-INF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.