Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to link css file in JSP ?

Posted on 2011-09-05
14
Medium Priority
?
1,316 Views
Last Modified: 2012-05-12
In Eclipse Web Project I have files:

WebContent\css\style.css
WebContent\pages\life\life.jsp

How do I link style.css in life.jsp ?

This does NOT work.
<link href="css\styles.css" type="text/css" rel="stylesheet">

Could you please suggest how do I link correctly ?
0
Comment
Question by:cofactor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
  • 2
  • +1
14 Comments
 
LVL 20

Accepted Solution

by:
chaitu chaitu earned 1000 total points
ID: 36482717
<link href="../../css/styles.css" type="text/css" rel="stylesheet">
0
 
LVL 47

Expert Comment

by:for_yan
ID: 36482725

check this:

http://stackoverflow.com/questions/6599254/include-a-css-file-as-inline-style-in-a-jsp
      

This sort of directive should work, but you will need to be sure of the path you're using:

<%@ include file="/path_to/your_css_file.css" %>

0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 36482779
<link rel="stylesheet" type="text/css" href="/ur Project name/css/styles.css" />

or
<link href="css/styles.css" type="text/css" rel="stylesheet">

ur mistake is backslas  change that \ into /
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:cofactor
ID: 36483365
>>>ur mistake is backslas  change that \ into /

No. This cant not work. You did not notice the folder structure closely.
0
 

Author Comment

by:cofactor
ID: 36483380
>>>/ur Project name

I dont want to put  Project Name there.
0
 
LVL 20

Expert Comment

by:chaitu chaitu
ID: 36483382
cofactor,

have u seen my coment
0
 

Author Comment

by:cofactor
ID: 36483392
>>>>have u seen my coment

Yes. I like relative path. But can  in every page  this costs two "/" and couple of dots.  Can we make it more simpler ?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 36483414
then use contenttype
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 36483415
>>
No. This cant not work. You did not notice the folder structure closely.

Have you tried ? without tiring your saying ?
0
 

Author Comment

by:cofactor
ID: 36483442
>>then use contenttype

not understood.

>>>Have you tried ? without tiring your saying ?

No.  I said because jsp lies  two folders down i.e ( "pages" , "life" ).   and  css is just under root .  So that should not work.

Do you still say that will work. how come ?
0
 
LVL 20

Expert Comment

by:Sathish David Kumar N
ID: 36483736
without puting / infront of the any folder then application will directly check in root folder only
0
 

Author Comment

by:cofactor
ID: 36483898
>>>without puting / infront of the any folder then application will directly check in root folder only

I tried when it is in HTML ..this does not work.

Do you mean when I deploy in server as JSP, this will work ?
0
 

Author Comment

by:cofactor
ID: 36484002
>>without puting / infront of the any folder then application will directly check in root folder only
>>Do you mean when I deploy in server as JSP, this will work ?

No..neither way ....it did not work even after deployment.
0
 

Author Comment

by:cofactor
ID: 36484086
>>><link href="../../css/styles.css" type="text/css" rel="stylesheet">

This worked.  

But not happy to see two many slas and dots .
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question