Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to incluse a css file in spring  RSS feed

 
andy kumar
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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66208
151
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: 66208
151
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!