This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

JSP Not able to Identify the JS, CSS file path

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have one strange issue, JSP cannot Identify the JS, CSS file path when URL pattern is /*. Let me explain in detail.

Irrespective of relative path my application should have to call Home.jsp. So for that I have specified URL pattern as /*. This logic is working fine.
The application is calling JSP page but It cannot call the JS file. In the below Sample code I try to print two alert massages. But I am able to see only one alert message "welcome". Not able to see the alert message in Hi.js file. I tried with all possible scenarios by changing path but its not working. CAN ANY BODY PLEASE HELP ME IN THIS.

One more thing I have to mention here when I change the URL pattern to some /xyz its working fine. Please Help me in this issue.

My Directory Structure.

RedirectApp
+-----WEB-INF
+-----Home.jsp
+-----Hi.js
Web.xml



Home.jsp




Hi.js


 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A URL pattern of /* matches everything -- including all references to images, CSS, and so on. Don't use it. That's a very common beginner's error.
 
Ranch Hand
Posts: 754
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use that <welcome-file-list> attribute in your web.xml.

So if someone type localhost:8080/yourApp/ your container will redirect the user to the mapped file.
 
vijay sachin
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank You very much guys for your help

I solved the problem by modifying web xml file and Home jsp Script tag.

Web.xml


In Home.jsp for the script tag src I used


 
He loves you so much! And I'm baking the cake! I'm going to put this tiny ad in the cake:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!