I am using Jboss and Netbeans to create Spring MVC web application on windows.
it runs on http://localhost/myapplication/
My project path is D:\Myapplication\
My JSP Views are in D:\Myapplication\web\jsp\
My Javascripts are in D:\Myapplication\web\js\
Controllers are in D:\Myapplication\web\src\java\controller\
I have created 1 controller which needs to create a HTML file at javascript location i.e. D:\Myapplication\web\js\
I am using Jquery.sheet to create a web spreadsheet.
and I want to use this HTML to load the Jquery.sheet for this i just want that Relative URL of that HTML stored in JAVASCRIPT location.
That depends on the request URL of the page for which jQuery.sheet is been executed.
First check in the browser address bar the absolute URL of the webpage which uses jQuery.sheet. It may be for example
http://localhost/myapplication/jsp/page.jsp.Then check/test in the browser address bar the absolute URL of the generated HTML file in question. It may be for example
http://localhost/myapplication/js/generated.html.The common path for both is only one folder level up:
../which will end up inhttp://localhost/myapplication. From there you can just access the JS folder and the generated HTML file byjs/generated.html.Summarized, the relative URL you need is
../js/generated.html.Update: as per the comment it turns out that you’ve elaborated your problem in a completely different perspective. You were talking about URL’s in client side perspective while you actually meant about local disk file system paths at the server side. In that case, just use
ServletContext#getRealPath()to convert a relative web path to an absolute disk file system path.