Based on the discussion in the comments (particularly from BalusC), it’s probably not worth doing anything more complicated than this:
<script>var ctx = "${pageContext.request.contextPath}"</script>
More Related Contents:
- Access Java / Servlet / JSP / JSTL / EL variables in JavaScript
- Call Servlet and invoke Java code from JavaScript along with parameters
- Bad Value for attribute href in a in jsp
- Dynamic Drop down values based on another dropdown [closed]
- Download a file by jQuery.Ajax
- How to escape JavaScript in JSP?
- Password encryption at client side [duplicate]
- Simple calculator with JSP/Servlet and Ajax
- Send a file as multipart through XMLHttpRequest
- How to detect browser closing?
- How to set the JSTL variable value in javascript?
- HTML Alignment Issue in one machine only (both IE8)
- sending variable from one jsp to another jsp
- Better way to prevent browser caching of JavaScript files
- Asynchronous file upload (AJAX file upload) using jsp and javascript [duplicate]
- How to embed a PDF in HTML page?
- How can i access javascript variables in JSP?
- How to pass an EL variable to javascript
- How to disable submit button once it has been clicked?
- How to use scriptlet inside javascript
- Populating JavaScript Array from JSP List
- Set Jquery ui active tab on page load/reload
- Permission denied to access property in IFRAME
- Not allowed to load local resource: file
- How to read an excel file contents on client side?
- Ordered JSONObject
- “Uncaught SyntaxError: Unexpected token , ” when create my object javascript
- Difference between defer().promise and Promise
- Displaying pdf from arraybuffer
- Alerts when navigating away from a web page