how to specify a custom stylesheet in scalate ssp - css

How to specify a custom stylesheet (external) to a SSP template (Scala Server Pages) in Scalate?
I tried specifying the html linking in the default.ssp file as follows.
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
<%= unescape(body) %>
</body>
</html>
However the stylesheet is not served by Scalatra (Jetty Web Server). I tried inserting the script through <%#include .. as well. Still no luck.
The web page is served without any stylesheet!

You need to have the style.css file as follows.
cd <YourProjectRoot>/src/main/webapp/
mkdir css
touch style.css
Create a style.css file inside a directory css which should be within the webapp directory, for the Scalatra to find out and serve the resource (stylesheet) appropriately.
Note: The folder should be named as css however the file can be named as anything.

Related

Express isnt loading CSS files

For some reason my CSS isnt loading, I use sass so it creates a css folder outside of the public folder, And it just keeps doing that after i try to move it
my folder directory
-node project
-public
+index.htmlFOlder structure
-css
+style.css
+index.js (my server)
Here are my links in the css and the middleware im using to serve this in the index
html
<link rel="stylesheet" href="../css/style.css">
nodejs
app.use(express.static('public'))
Note im now also getting an error -
"Refused to apply style from 'http://127.0.0.1:3000/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."
To serve the multiple static files you need to add multiple middlewares in your index.js file
app.use(express.static('public'));
app.use(express.static('css'));
and link to CSS with this line in your index.html file
<link rel="stylesheet" href="style.css">

Failed to load resource 404 style.css firebase

Receiving the following console log from my static website
Failed to load resource: the server responded with a status of 404 ()
on style.css
Project structure
root - home.html
folder inside root - styles
file inside 'styles' folder - style.css
(It's a simple website, for testing firebase)
I've used firebase to create the instance of my website and it outputted my html to a public folder with index.html but no css files.
Like so public/index.html
I've added inline css to account for this by using <style media="screen"> and it works but it's still not reading/finding my style.css file
style.css link inside index.html (firebase created)
<link rel="stylesheet" type="text/css" href="../style/style.css">
Looked into other answers but they're using bootstrap supplied cdn/url. I want to be able to use the one I created.
Firebase hosting will only host the files under your public folder. Which means that your style folder is not being uploaded and thus index.html can't detect the css file.
You need to move your style folder to have it inside the public folder and change the link to:
<link rel="stylesheet" type="text/css" href="style/style.css">

How to load a new css file by not loading existing css file

I am using spring, when i run my project in web common.css files and js files will load. Now, when i run project the existing css file should not load, new css file should load in runtime.For example, if i open my project in web then a.css file sholud load , if i open it from android b.css file should load.
In spring i used web interceptor class http://alvinalexander.com/java/jwarehouse/spring-framework-2.5.3/src/org/springframework/web/servlet/mvc/WebContentInterceptor.java.shtml, in this class i am getting file paths from lookup path variable when i run my project . Here i tried to update file path but it is not working.please help me how can we do it.
Thanks in advance.
Add that css file which you want to override other after that file.
For example you you want to override 'a.css' to 'b.css' than
<link rel="stylesheet" type="text/css" href="b.css">
<link rel="stylesheet" type="text/css" href="a.css">
Here a.css will override b.css

Webapp does not load images

I'm developing a webapp on Eclipse and this is the file system directory structure:
myapp
- src
- build
- WebContent
- pages
- css
- images
- modules
- META-INF
- WEB-INF
When I run this webapp with Tomcat (Run from Eclipse) I can load in the browser
the jsp pages contained in (myapp -> WebContent -> pages) using for example this URL:
http://hostname:8080/myapp/pages/somepage.jsp
However the problem is that the loading of the css and images in such somepage.jsp fail.
In the code of the somepage.jsp I pointed the css in this way:
<link href="../css/new_style.css" rel="stylesheet" type="text/css"/>
And the image in this way:
<img src="../images/someimage.png"/>
Problem is I have no clue why such images and css are not loaded.
The problem is in the relative path, always a safer approach to do something like
<link href="<%=request.getContextPath()%>/css/new_style.css" rel="stylesheet" type="text/css"/>
or a JSTL equivalent
<link href="${pageContext.request.contextPath}/css/new_style.css" rel="stylesheet" type="text/css"/>
than you're starting from the root, accounting for context path as well
Better way is to use ${pageContext.request.contextPath} as it returns the name of the application's context.
For ex,
myapp/css/new_style.css can be dyanmically formed as {pageContext.request.contextPath}myapp/css/new_style.css
Have a look here to know What does "./" (dot slash) refer to in terms of an HTML file path location?

webpage unable to load css file

this is a newbie question for you guys.
In file
/home/myhome/apache-tomcat-6.0.29/webapps/view/test.jsp
I have <link rel="stylesheet" type="text/css" href="WEB-INF/resources/view.css"/>
and the view.css file is located at
/home/myhome/apache-tomcat-6.0.29/webapps/view/WEB-INF/resources/view.css
For some reason, it's not loading the css file. But when I put the css file in the same directory as the jsp page and change href accordingly, it worked. What did I do wrong in my attempt to load the file from another folder?
Thanks alot.
try
Firebug, to debug if path is correctly loaded or not. As i can see it issue with path so you have to debug.
http://www.ehow.com/how_2221659_debug-css-firebug.html
But you can try with this line instead
<link rel="stylesheet" type="text/css" href="/view/WEB-INF/resources/view.css" />
Since I am using tomcat, I guess tomcat just won't let a page access anything in the WEB-INF folder, I moved the file else where not in WEB-INF, it worked...

Resources