Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Unable to incluse a css file in spring  RSS feed

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am unable to include a css file in my jsp. My configurations are as follows:-

web.xml

<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>

</servlet>

<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/edo/*</url-pattern>
</servlet-mapping>

spring-servlet.xml
<bean name="/home"
class="com.protogalaxy.edo.web.HomeController">
</bean>

<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp"/>
</bean>

JSP page

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title></title>
<link href="scripts/mystyle.css" rel="stylesheet" type="text/css"/>
</head>

Controller code
ModelAndView mav = new ModelAndView("home");

URL
http:// localhost/MYAPP/edo/home

My jsps are in WEB/-inf/jsp/home.jps and my css file is in WEB-INF/jsp/scripts/mystyle.css. Could anyone please help me in knowing what I am missing?
Thanks in advance.


Thanks
Andy
 
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) Nothing under WEB-INF can be served. Move any CSS, script and image files out of WEB-INF.

2) Avoid page-relative URLs. User server-relative URLs. See the JSP FAQ.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66804
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a general JSP issue, so it's been moved to the JSP forum.
 
andy kumar
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you for the quick reply. Following your suggestion I was successfully able to include my css file in the jsp page.

Once again thanks for the help.

Thanks
Andy
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!