I use the following code that is at the beginning of my jsp to activate the download dialog box on my jsp I have this one page that will allow file downloads without having to go to another page:
Then I have several links displayed: [code] < a class="a" href="main.jsp?downfile=C:\\data\\<%=allfiles[i+1]%>">DOWNLOAD</a> [code] I know this isnt a secure way of doing this but I am on a intranet. The problem I am having now is that when I click on one of the links and download the file and then open it, I get the contents of the file plus concatenated to the end of it is the first few HTML lines of the actual jsp that I downloaded the file from. Before I was just getting the first few lines of html from the jsp, not the actual contents of the downloaded file. This is an example of what I am getting note this is the actual contents of a text file I download from my app: This is the contents of the file that I downloaded.//This is where the file contents ends. This is where the html code is appended.
Any ideas? TIA! BTW, I went to ApacheJServ because they wont let me use tomcat
Is there HTML content after the code you displayed above? If so, yeah it's just gonna get streamed out after your file. JSP is a poor technology choice for this type of function. You'd be best served to move this code to a servlet. bear
Look at what the implicit "out" is in a JSP - it is a JspWriter! When you write the value that the file read reads through a Writer, it will perform some sort of character conversion according to what the writer thinks the character set is - this is unlikely to be what you want it to be. Therefore, like Bear says, do this in a servlet where you have total control. Bill