Skip to content

Instantly share code, notes, and snippets.

@aakash14goplani
Last active April 4, 2020 16:38
Show Gist options
  • Save aakash14goplani/f5cc93b5552ba34fbe5c979d6ec3ad01 to your computer and use it in GitHub Desktop.
Save aakash14goplani/f5cc93b5552ba34fbe5c979d6ec3ad01 to your computer and use it in GitHub Desktop.
Referencing static files in JSK

Rendering static files in JSK

  1. Create a folder with name of your site, e.g. If your site that you're currently working on is named as Hello_World so your folder should also be named as Hello_World and be placed under JSK_Installation_Path\App_Server\apache-tomcat-7.0.42\Sites\webapps\cs
  2. Place all the static assets like .js, .css or image / other files within this folder.
  3. We can create a reference path to these files using request.getContextPath():
    <link rel="stylesheet" href='<%=request.getContextPath() + "/Hello_World/css/home.css" %>'>
    <script src='<%=request.getContextPath() + "/Hello_World/js/home.js" %>'>
    <img src='<%=request.getContextPath() + "/Hello_World/img/home.jpg" %>'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment