Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

struts problem determining the location of css file.

Posted on 2006-05-26
9
Medium Priority
?
411 Views
Last Modified: 2008-02-01
I have a small struts application. I am having difficutlies get to my css file using the following.

<link rel="STYLESHEET" TYPE="text/css" href="/css/styles.css" >

what should i put in the href. My styles.css is located in project/WEB/css

how do i determine the relative path.

Thanks
0
Comment
Question by:muthiahmerchant
9 Comments
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 16771020
Hi,

It's relative path to you jsp or html file.
If you jsp/html put in project/WEB and your .css put in project/WEB/css,
so href should be href="./css/styles.css"

sompol
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 16771033
but if you define href like "/css/style.css" that mean it is absolute path and you have to put .css file in root folder.
0
 
LVL 1

Author Comment

by:muthiahmerchant
ID: 16771535
the problem is I am using struts and the urls to access struts does not represent the actual location of the jsp file

for example to go to the login page I use http://localhost/project/login.do, but login.jsp resides in project/web/jsp/login.jsp

hence i think my relative path should not be with respect to the url. is there any other way.

Thanks for your help
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.

 
LVL 16

Expert Comment

by:suprapto45
ID: 16771667
Is this CSS called from login.jsp?

Try to use this as well
<link rel="STYLESHEET" TYPE="text/css" href="css/styles.css" >

David
0
 
LVL 1

Author Comment

by:muthiahmerchant
ID: 16772248
The css is called from another file which is part of struts tiles
0
 
LVL 92

Expert Comment

by:objects
ID: 16772928
> the problem is I am using struts and the urls to access struts does not represent the actual location of the jsp file


use the base tag to specify the base url for your pages

http://www.w3schools.com/tags/tag_base.asp
0
 
LVL 11

Expert Comment

by:sompol_kiatkamolchai
ID: 16773735
or try to use this one.

href="<%=request.getContextPath%>/web/css/style.css"
0
 
LVL 14

Accepted Solution

by:
boonleng earned 1000 total points
ID: 16774087
You can try using <html:rewrite> to render the url path.
<link rel="STYLESHEET" TYPE="text/css" href="<html:rewrite page="/css/styles.css"/>" >
0
 
LVL 1

Author Comment

by:muthiahmerchant
ID: 16776573
thanks to all your comments.

since I am using struts I will go with the boonleng's solution.

Thanks again
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

580 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