This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

CSS href links to the wrong file in JSP

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote a very simple application using Java, JSP and Servlets with Glassfish web server. I use the Eclipse IDE with its default directory structure. My directory structure is shown in the attachment. However if I run my webapp I see the link to my css in the browser view source window. But when I click on the link it navigates me to different URL than the one shown and throws me with a 404 file not found exception.

MY SERVLET CODE



JSP HEADER CODE



VIEW SOURCE



ACTUAL LINK POINTING TO WITH A 404 EXCEPTION

http://localhost:8080/Login/css/index.jsp

Any help would be appreciated!
directoryStructure.png
[Thumbnail for directoryStructure.png]
Directory Structure
 
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ACTUAL LINK POINTING TO WITH A 404 EXCEPTION

http://localhost:8080/Login/css/index.jsp



Yes, that file does not exist. Is that what you are tying into the address bar? What happens if you type in the correct URL?
 
Ram Prakash Jayapalan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. What I see in the view source of a chrome browser when I try pasting it in the browser say it does not display the css code instead the browser reloads to this URL which it does not even exist!
 
Bear Bibeault
Marshal
Posts: 67273
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you running the app inside Eclipse? What happens when you run the app outside of Eclipse in a real environment?
 
Ram Prakash Jayapalan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I am developing in Eclipse. Meanwhile is it necessary to have a <welcome-file> in you webapp? In my case my webapp root is being handled by a servlet. Based on the session, it redirects to the respective jsp page. My DD snippet is shown below



But when I try to use a welcome file (index.jsp) instead of handling through a servlet, the css works fine. It stops working when I bring in a servlet. All these happen in eclipse environment. Not sure if response.sendRedirect() would be the issue as well!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!