Get website URL for XML file JSP-Java

antaspAddiday

New Member
Let's say i have created the file \[code\]String path = application.getRealPath("userSearchFolder");String name = path + "/" + (String) session.getAttribute("username") + ".xml";File file = new File(name);\[/code\]And later I want to make it available as a link, for example \[code\] <a href"<%=file.toURI()%>">File</a>\[/code\]What happens is I get the directory path not url path -> \[code\]file:/D:/Documents/NetBeansProjects/2012/GATE_Project/build/web/userSearchFolder/mjoraid.txt.xml\[/code\]And when it reaches Firefox, I hover over the link and what i see is \[code\]file:///D:/Documents/NetBeansProjects/2012/GATE_Project/build/web/userSearchFolder/mjoraid.xml\[/code\]When I right click and choose Copy link Location and paste it in URL the xml file opens, but when I click the link, nothing happens. How could I get a link like this \[code\]http://localhost:8080/GATE_Project/somepage/somepage/mjoraid.xml\[/code\]
 
Back
Top