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

  • SEARCH
  • Home
  • 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 6767195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:55:20+00:00 2026-05-26T14:55:20+00:00

I installed SpringSource Tool Suite 2.8.0. I’m trying to include a JS file in

  • 0

I installed SpringSource Tool Suite 2.8.0.
I’m trying to include a JS file in a JSP, using the Spring MVC template as a starting point.
My JSP looks like this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<html>
<head>
    <title>Home</title>
    <script type="text/javascript" src="/a.js"></script>
</head>
<body>
    Hello world!  
</body>
</html>

a.js is under src\main\resources and looks like this:

window.alert("A");

The result is that “Hello world!” gets printed without the alert 🙁

I tried putting the JS file in different places, changing the src to be with/without “/”, and even adding a servlet-mapping in web.xml to use “default” servlet for “*.js”.
Nothing seems to work.

What am I doing wrong?

  • 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-05-26T14:55:21+00:00Added an answer on May 26, 2026 at 2:55 pm

    is the js file getting included in your .war file? I usually put my js and css in src/main/webapp. something like src/main/webapp/js and src/main/webapp/css.

    Secondly, you can reference it appropriately using c:url which will take care of putting the app context on there and stuff.

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

    You can use firebug or chrome’s developer tools to see if you are getting a 404 for a.js and see what path it is actually requesting.

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

Sidebar

Related Questions

I'm fairly new to the Spring framework. I have recently installed SpringSource Tool Suite
I am using the current version of SpringSource Tool Suite with the Groovy/Grails plugin
I'm learning to use Springsource Tool Suite (STS) and the Spring framework for development.
I am working on SpringSource Tool Suite with Spring Roo. Everything was working well
I have installed Springsource Tool Suite v2.7.2 with Groovy and Grails support on Ubuntu.
I'm trying to install SpringSource Tool Suite into an existing Eclipse install (3.7 Indigo).
I'm trying to install Subclipse in SpringSource Tool Suite (version 2.8.1.RELEASE). Following the instructions
I'm getting a strange error message in SpringSource Tool Suite (eclipse) when I try
I'm kicking the tires on Grails 2.0.0M1 and Springsource Tool Suite 2.7.1, but I'm
I was trying to work on the Spring Roo Demo project @ www.springsource.org/roo/guide?w=beginning and

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.