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

Why is my css acting weirdly?

Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Folks,
This is my folder structure in eclipse . I'm attaching a screen shot of the same .

As you see I have two jsp files in the pages folder one is search.jsp and the other ConsumerAddEdit.jsp
I reference my css called CIS.css placed in the css folder .
In search.jsp , I reference it using --

But , this doesnt work in ConsumerAddEdit.jsp and I have to modify it to

Any idea why this discrepancy occurs??

Thanks



[Thumbnail for Snippet.JPG]



Learning and Learning!-- Java all the way!
Tarun Bolla
Ranch Hand

Joined: Jun 20, 2011
Posts: 89
The best thing you could do is ... export it as war...and then extract it using some 7zip or winrar...and then see the directory structure

. indicates present directory
.. indicates parent directory
Hence relative to pages directory where you placed the JSP... css folder belongs to .. (parent) directory. So you should use ..
And if you are planning to use that css in test.jsp, go ahead with a single dot or no dot.

Sorry for somany edits!!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60996
    
  65

There is a JspFaq entry on this issue. You are using page-relative URLs, in the href. Don't. Fragile and error-prone.

URLs should be server-relative, beginning with the context path.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi Bear, thanks for your reply!
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

Hi , another related doubt.. how do I use this in servlets?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60996
    
  65

Get the context path from the request.
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
@Vic : check whether the second method works in the first case. According to your current situation the second seems to be the best option. But if you have moved your Search.jsp from context root to the pages folder then it might be a case that the browser is using the cache page. Modifying the page and then doing view source on browser might show you whether browser is using the page from pages folder or from its cache.

P.S the first method is fine if the page is directly under context root. Also as @Bear pointed out the URL should be server relative.
Vic Hood
Ranch Hand

Joined: Jan 05, 2011
Posts: 477

@ashutosh :Yes Ive been using the JspFaq pointed out by Bear and its working fine
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why is my css acting weirdly?