Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8512135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:11:57+00:00 2026-06-11T04:11:57+00:00

I have a Java EE application and in the application I have the following

  • 0

I have a Java EE application and in the application I have the following structure.

WEB-INF
    layout
        header.jsp
    styles
        main.css

I want to include the main.css in the header.jsp. Which I am attempting to do with the following (where … is the path):

<link rel="stylesheet" href="..."> 

However, I can’t seem to get the right path. I have tried each of the following with no luck:

../styles/main.css
/styles/main.css
styles/main.css
/WEB-INF/styles/main.css
WEB-INF/styles/main.css

What is the correct path?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T04:11:58+00:00Added an answer on June 11, 2026 at 4:11 am

    First of all, resources in /WEB-INF folder are not directly publicly accessible without a intermediating (front controller) servlet (this also covers JSP files themselves! the <jsp:include> runs at webserver, not at webbrowser). So you’ve to put CSS (and JS and image) files outside the /WEB-INF folder.

    WebContent
     |-- WEB-INF
     |    `-- layout
     |         `-- header.jsp
     |-- styles
     |    `-- main.css
     :
    

    Assuming that it’s now in /styles/main.css, then you can reference it as follows:

    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/styles/main.css" />
    

    Using ${pageContext.request.contextPath} (which prints the current context path with a leading slash and thus makes the CSS URL guaranteed relative to the domain root) is not necessary per se, but it is your safest bet as the current request URL is unknown. All relative paths in HTML <link>, <script>, <img>, <a>, etc elements are namely namely by the webbrowser resolved relative to the current request URL (as you see in browser’s address bar). As long as it’s unclear what your request URL is, I can’t answer the right CSS path without using ${pageContext.request.contextPath}.

    See also:

    • Moving resources under WEB-INF
    • Browser can't access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application with a following structure: src + main +-+ java
I have the following structure in a Java Web Application: TheProject -- [Web Pages]
I want a Java application to have a directory structure like the following (like
I have an application that has the following structure $TOMCAT_HOME/webapps/myapp |-css |-myapp.css |-js |-myapp.js
I have a EAR application with following structure: app.ear |-- app.war `-- META-INF `--
I have a java application where main class is dependent with some other classes.
I have a java-application using JDBC for database interaction. I want to do a
I have a java application, and I want to use rails migrations for this.
I am working on a legacy application which have a .war with following structure
I have a Spring MVC based Web Application with Hibernate. Following is the directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.