I wrote a relative path in JSP but it's not working

248 views Asked by At

I created a webservice project named FirstTest using dwr.

In WebContent folder I have a JSP. After successful deployment there is a JS

localhost:8080/FirstTest/dwr/interface/getdata.js

So in JSP I wrote

<script type="text/javascript" src="/FirstTest/dwr/interface/getdata.js">

Now I rename the project to SecondTest then the js location changed to

localhost:8080/SecondTest/dwr/interface/getdata.js

and I have to rewrite the JSP file path. Then how to use relative path instead? I tried

<script type="text/javascript" src="../dwr/interface/getdata.js">

and

<script type="text/javascript" src="/dwr/interface/getdata.js">

but both not working.

Thx for any help.

1

There are 1 answers

2
A Paul On
<script type="text/javascript" src="/dwr/interface/getdata.js">

In this line the first "/" means the the root directory of your site. Check the deployed root directory in your server and make sure from root directory this file path is present. Rest looks good on this line.