/    Sign up×
Community /Pin to ProfileBookmark

How to include .css file in jsp file

Hi,

I have included a .css file in a .jsp file using following tag [B]<link rel=”stylesheet” href=”../../css/timesheet.css” type=”text/css”>[/B].
Preview of jsp file is fine but when I upload the jsp file and .css file to server, Look and feel of the screen is changing. When I paste the style code in jsp file, look and feel is fine.

Can some body suggest me that why the look and feel is changing when I put the style code in css file and include it in jsp.

Thanks in advance.
Manish

to post a comment
CSS

17 Comments(s)

Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 11.2006 — are you sure about the path?

could you post the code?
Copy linkTweet thisAlerts:
@hjainmauthorJan 11.2006 — Yeah path is correct. I am pasting the jsp code which includes the css file. Code is below:

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Cost VPF </title>

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

</link>

<script language="JavaScript" type="text/JavaScript" src="../../scripts/ts.js"></script>

</head>
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYJan 11.2006 — i don't see any coding, i only see markup here?!
Copy linkTweet thisAlerts:
@pcthugJan 11.2006 — You don't need to close the link tag so lose the [I]</link>[/I] that may be your problem, but if not...

and if all else fails try:
[CODE]
<style type="text/css">
<!--
@import url("../../css/timesheet.css");
-->
</style>
[/CODE]


This may just work?
Copy linkTweet thisAlerts:
@ray326Jan 11.2006 — Don't push it out to the browser to include. Use the JSP include tag to include it in the head of the page as it's being built.
Copy linkTweet thisAlerts:
@hjainmauthorJan 12.2006 — Hi,

Thanks to all for the reply. I have tried following :

  • 1. With out putting the </link> tage as well.


  • 2. <style type="text/css">

    <!--

    @import url("../../css/timesheet.css");

    -->

    </style>

    This also does not work.


  • 3. Including with JSP include tag as <%@ include file="../../css/timesheet.css"%> is also not working.


  • What can be the issue? Any suggestion can help me out.

    Regards,

    Manish
    Copy linkTweet thisAlerts:
    @ray326Jan 12.2006 — 3. Including with JSP include tag as <%@ include file="../../css/timesheet.css"%> is also not working.[/QUOTE]Define "not working." Does the JSP compile fail? If not then what appears in the page (view source)? Did you put this inside style tags?

    <style type="text/css">

    <%@ include file="../../css/timesheet.css" %>

    </style>
    Copy linkTweet thisAlerts:
    @chongJan 12.2006 — You mentioned path is correct, how sure are you?
    Copy linkTweet thisAlerts:
    @pcthugJan 12.2006 — Try putting the css file in the same directory as your jsp file and see if that works.
    Copy linkTweet thisAlerts:
    @hjainmauthorJan 12.2006 — Jsp compilation does not fail. Also I tried the below also..

    <style type="text/css">

    <%@ include file="../../css/timesheet.css" %>

    </style>

    I also tried putting the .css file in the same directory also. But everything is failing.
    Copy linkTweet thisAlerts:
    @pcthugJan 12.2006 — Well it must be your css file as it looks like you have tried nearly everything, try calling the timesheet.css file from a simple HTML page and add a class or check the body to see if it worked. This will determine whether there is something in your jsp, or server interfering with the styling or whether its just the stylesheet.
    Copy linkTweet thisAlerts:
    @ray326Jan 13.2006 — Jsp compilation does not fail. Also I tried the below also..

    <style type="text/css">

    <%@ include file="../../css/timesheet.css" %>

    </style>

    I also tried putting the .css file in the same directory also. But everything is failing.[/QUOTE]

    Does the content of the CSS file appear in the page when you do a view source?
    Copy linkTweet thisAlerts:
    @ray326Jan 13.2006 — This will determine whether there is something in your jsp, or server interfering with the styling or whether its just the stylesheet.[/QUOTE]Some Java servers aren't configured by default to serve *.css as text/css content. But that only matters to certain browsers when the browser requests the file. Doing it with an include should just work. He's really got something strange going on.
    Copy linkTweet thisAlerts:
    @pcthugJan 14.2006 — Some Java servers aren't configured by default to serve *.css as text/css content. But that only matters to certain browsers when the browser requests the file. Doing it with an include should just work. He's really got something strange going on.[/QUOTE]

    I agree!

    Q. Is this the only .css file that you're trying to link too?
    Copy linkTweet thisAlerts:
    @sambit19Feb 15.2008 — you can add the following things inside the <head> tag

    <meta http-equiv="Content-Style-Type" content="text/css">

    <title> Home </title>

    <html:base/>

    <link HREF="../theme/screens.css" REL="stylesheet" TYPE="text/css" >


    I had the same problem but doing so solved the issue.


    Thanks

    Sambit.
    Copy linkTweet thisAlerts:
    @gauravleoheartJun 16.2010 — this can be the issue due to foloowing problem...

    whenever u include a file in jsp using include tag it doesnt get compiled after u makes to it....itself...

    so two things which u can try and do is close the serer and restart it so it forcefully compile the file or if u are using unix try using touch command...try it..

    and u should include it using link tag... and are the both files on same server...
    ×

    Success!

    Help @hjainm spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...