The images inside the header are not reachable also css files are not linked correctly !!, here\'s the hierarchy of my files" />
开发者

Problem in files paths when trying to include them into index page

When I make include <%@include file="../WEB-INF/jspf/Header.jspf" %>

The images inside the header are not reachable also css files are not linked correctly !!, here's the hierarchy of my files

Problem in files paths when trying to include them into index page

in StudentIndex.jsp I make like this

<link type="text/css" rel="stylesheet开发者_Go百科" href="../css/StudentStyle.css"/>
<%@include file="../WEB-INF/jspf/Header.jspf" %>

and in the Header.jspf

<link href="../css/Style.css" type="text/css" rel="stylesheet"/>
<img src="../images/iuglogo.gif" alt="IUG logo" id="IUGlogoStyle"/>

EDIT

when I run StudentIndex.jsp, all the files are running correctly

http://localhost:8080/OnlineQuerySystemNew/Student/StudentIndex.jsp

but when the request is forwarded from the servlet to the StudentIndex page no images and no css files are attached

http://localhost:8080/OnlineQuerySystemNew/StudentManagementServlet?param=activationOptions


  • Get JSTL
  • Include taglib in your jsp pages like this -

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

  • Use url tag get rid of your pain. Like this -
<link rel="stylesheet" type="text/css" href='<c:url value="/css/Style.css" />' />
<img src='<c:url value="/images/iuglogo.gif" />' alt="IUG logo" id="IUGlogoStyle"/>


You can try to put this code in your .jspf file:

<link href="<%= request.getContextPath() %>/css/Style.css" type="text/css" rel="stylesheet"/>
<img src="<%= request.getContextPath() %>/images/iuglogo.gif" alt="IUG logo" id="IUGlogoStyle"/>

You can also change <%= request.getContextPath() %> to ${pageContext.request.contextPath} if you are using jstl EL.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜