I have tried to open a PDF file from the local disk.
For example the Location is:
E:/files/IT/cat1/cat1Notification.pdf
But during runtime the link changes to:
http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf
How to do i get rid of http://localhost:8080/Office_Automation/ from the link and open the file?
I have used
<a href="<%=path%>">click here</a>
To open the local file you need to use the file scheme in your URL
As you path is a Windows path
E:/files/IT/cat1/cat1Notification.pdf, the link’s href needsfile:///added before the your jsp’s<%=path%>variable, so that the browser knows it needs to open a local file on the user’s machine.So your link should look like this
Which in your browser will resolve to
file:///E:/files/IT/cat1/cat1Notification.pdfWithout the file scheme the browser assumes that your link is relative to the webpage and tries to resolve the link by making a request to your webapp. This is why you were getting
http://localhost:8080/Office_Automation/E:/files/IT/cat1/cat1Notification.pdf