1

I followed the steps for building java web application using the following guide https://guides.gradle.org/building-java-web-applications/

Now there is no web.xml generated. Trying to find out where to put my css and javascript files so that they can be accesible in jsp and html.

1 Answer 1

3

Static resources should go in src/main/webapp. Anything in this folder will be copied into the root of the war file.

For Example, if you place the following index.html and site.css in src/main/webapp, you should get a page with Hello, World in blue text.

index.html

    <html>
    <head>
        <link href="site.css" />
    </head>
    <body>
        <h1>Hello, World</h1>
    </body>
    </html>

site.css

    h1 {
        color: blue;
    }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Dusty, I was putting css and javascript files in webapp folder but I was using forward slash (/) like this <link rel="stylesheet" href="/app.css">. I removed the forward slash and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.