File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why is my css acting weirdly?

 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Snippet.JPG
File Structure
[Thumbnail for Snippet.JPG]
 
Tarun Bolla
Ranch Hand
Posts: 89
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear, thanks for your reply!
 
Vic Hood
Ranch Hand
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi , another related doubt.. how do I use this in servlets?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Get the context path from the request.
 
Ashutosh Limaye
Ranch Hand
Posts: 58
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@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
Posts: 477
Eclipse IDE Java Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@ashutosh :Yes Ive been using the JspFaq pointed out by Bear and its working fine
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic