• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using external CSS file in JSP in struts 2 framework

 
Harish V Gupta
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys, using CSS in struts 2 is giving me really hard time. No error is being thrown but the CSS style is not being applied on the JSP's elements. Following is the code :
CSS Code :


JSP Code:
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harish,
This has little to do with struts but have you tried using tools like "firebug" from firefox. Have you verified the HTML code using view source after rendering?

Looking into the code what I could see is most probably the CSS file is not picked due to the href path
1. Why would you want to give a url value? why dont you give it directly something like2.Verify where if the css file is located in the right place as mentioned.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are there <style> elements in your CSS file?
 
Shankar Tanikella
Ranch Hand
Posts: 329
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point, for a moment I didn't see that
 
Harish V Gupta
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply guys. As per your suggestion, I corrected the path name and I am using it as follows :


It's working fine but there is a new problem that I have come across. I have a validate method in my action class to validate one of the contents on my sign up page. On validation fail, the message is being shown on the the sign up page but css and javascript is not being applied. I checked using firebug and it's throwing error which says that resource is not found.
The directory structure is attached.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic