Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 653
  • Last Modified:

I have an <a> tag where the href property is pointing to a local file on my c drive at "c:\tmp". Is does not work in Tomcat 7.

I have an <a> tag where the href property is pointing to a local file on my c drive at "c:\tmp".  Is does not work in Tomcat 7.  

However if I take the page source and create a text file called "MyFile.html" and then I open it in IE or Firefox the <a> links work fine.   I am thinking there must be some security issue with Tomcat so that the webpage can't use the local file.

Any suggestions on how I can use local files for my <a> tag href properties and have the link work in Tomcat 7?
0
gdkinney_2
Asked:
gdkinney_2
1 Solution
 
thehagmanCommented:
What is the HTML source when the file is served by TomCat? Are you sure it's not rather a security feature of your browser not to refereence local files from the internet?
0
 
gdkinney_2Author Commented:
Its not the browser because I run the app in Tomcat and when the page is served I just take the page source and save it in a text file.  I then open it in the same browser outside of Tomcat and the links work fine.
0
 
Dave BaldwinFixer of ProblemsCommented:
Files and pages on a web server run under a limited user that is usually not allowed access outside the web directories.  You can open it in your browser because when you open it using a 'file://' protocol, it opens under your user.  If you try to include that link in a page coming from the web server, it will not work in your browser because current security rules prevent a web page from accessing the local computer.  http://code.google.com/p/browsersec/wiki/Part2
0
 
Pramod KumarCommented:
A java web application deployed in tomcat cannot access a file outside its deployed folder in a direct access mode as you are doing (by <a href="">). You have two options here:

1. Copy your file to the deployed folder and use a relative path (c:\temp\myfile.txt is an absolute path) under href.

2. If you are java programmer, then you can read any disk file using servlet and send to the user's browser.
0
 
Sharon SethCommented:
All resources in a web app should be put in the deployed folder . Try putting your file somewhere in WEB-INF
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now