aspose file tools*
The moose likes JSP and the fly likes CSS problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "CSS problem" Watch "CSS problem" New topic
Author

CSS problem

krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hi

I have a CSS file defined inside my jsp file with the tag
<link rel="stylesheet" href="./css/global.css" type="text/css" /> i am able to view the preview on my desktop but when i deploy my ear file on the server,its not able to pick my css file . iam actually surprised with it.

Can anyone help me in this regard .

Thanks

krish
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

See:
http://faq.javaranch.com/java/RelativeLinks

It may contain the solution to your problem.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hi,

Its not able to pick the file itself now,i am not able to view it in the preview itself,

Can anyone please help me, iam doing lot of things but nothing is working out.

Thanks
krish

Originally posted by krish chaitu:
Hi

I have a CSS file defined inside my jsp file with the tag
<link rel="stylesheet" href="./css/global.css" type="text/css" /> i am able to view the preview on my desktop but when i deploy my ear file on the server,its not able to pick my css file . iam actually surprised with it.

Can anyone help me in this regard .

Thanks

krish
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

"The preview" means almost nothing to us.

Where is your JSP?
Where is your CSS file?
How are you accessing your JSP?... directly from a browser, or are you
forwarding from another resource, such as a controller servlet?

If you've changed the link since your first post, please post the new version.
[ December 06, 2007: Message edited by: Ben Souther ]
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hi,

As mentioned in the link i have changed the link tag with the following & now its not displaying it in the preview itself.
<link rel="stylesheet" ref="${pageContext.request.contextPath/css/global.css}" type="text/css" />

This is not working at all.

Please help me

Thanks
krish
Originally posted by krish chaitu:
Hi

I have a CSS file defined inside my jsp file with the tag
<link rel="stylesheet" href="./css/global.css" type="text/css" /> i am able to view the preview on my desktop but when i deploy my ear file on the server,its not able to pick my css file . iam actually surprised with it.

Can anyone help me in this regard .

Thanks

krish
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I don't know what you're talking about when you say 'the preview'.
There is no such thing as a 'preview' in JSP.

If you're using a wysiwyg HTML editor that doesn't understand JSP, then I wouldn't expect it to be able to show the CSS sheet because it will have no idea how to interpret ${pageContext.request.contextPath}. If that's not what you mean then you'll have to start by explaining what 'the preview' means to you.
pulijala hari
Ranch Hand

Joined: May 14, 2005
Posts: 70
why dont you get the css file using the getContextPath() method?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by pulijala hari:
why dont you get the css file using the getContextPath() method?


Did you read the JSP FAQ entry mentioned earlier in this thread?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Originally posted by krish chaitu:

<link rel="stylesheet" ref="${pageContext.request.contextPath/css/global.css}" type="text/css" />
Careless mistakes will shoot you down every time. Carefully check the syntax of your statement and be sure that you understand it before using it.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hi,

Ihave went through the thread & also done the changes as mentioned in the thread but still not able to get past this error.if iam making any careless mistakes ,please let me know what mistake i have done.

Thanks
krish



Originally posted by Bear Bibeault:
Careless mistakes will shoot you down every time. Carefully check the syntax of your statement and be sure that you understand it before using it.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Consider your use of the EL. Are your braces, { and }, in the right places?
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hi,

My braces are at the right place.but not able to display the page.

Thanks
krish


Originally posted by Bear Bibeault:
Consider your use of the EL. Are your braces, { and }, in the right places?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

Originally posted by krish chaitu:
My braces are at the right place.
No, they are not.
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hii,

Here is how iam using, just tell me if it is wrong,what need to be done
<link rel="stylesheet" ref="${pageContext.request.contextPath}/css/global.css" type="text/css" />


Thanks
krish



Originally posted by Bear Bibeault:
No, they are not.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by krish chaitu:
Hii,

Here is how iam using, just tell me if it is wrong,what need to be done
<link rel="stylesheet" ref="${pageContext.request.contextPath}/css/global.css" type="text/css" />


Thanks
krish





This is not what you posted earlier.
See: http://faq.javaranch.com/java/AvoidRedHerrings
This now looks OK.
Which.. brings us back to my earlier question.
What are you using to view this JSP (what are you talking about when you say "PREVIEW')?
[ December 06, 2007: Message edited by: Ben Souther ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61224
    
  66

That is not what you posted earlier.

If the css folder is at the root of your web app (in the same folder as WEB-INF), this will work.

You will be able to do a View Source from the browser to see the resulting URL, and then use that URL in the address bar to determine if the address is correct.
[ December 06, 2007: Message edited by: Bear Bibeault ]
krish chaitu
Ranch Hand

Joined: Oct 09, 2007
Posts: 32
Hii,


Thanks all for your help, it worked fine

Thank you very much.

Regards
krish


Originally posted by Ben Souther:


This is not what you posted earlier.
See: http://faq.javaranch.com/java/AvoidRedHerrings
This now looks OK.
Which.. brings us back to my earlier question.
What are you using to view this JSP (what are you talking about when you say "PREVIEW')?

[ December 06, 2007: Message edited by: Ben Souther ]
 
 
subject: CSS problem