This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes Access denied after file downloading Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Access denied after file downloading" Watch "Access denied after file downloading" New topic
Author

Access denied after file downloading

Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
Hi, I'm currently working on file uploading and downloading from client site to the server's site. One problem that I'm facing currently is after I downloaded files from the jsp, I received an "Error on page" error. When I double click on the exclaimation icon at the bottom left corner, the message details says that "Access is denied". I managed to download the file to the any location i wish, but after download, i just can't navigate to other page even though i click at the link.
Any suggestion will be highly appreciated... Thank you very much
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

We've seen this problem before with file uploading. The problem is that the servlet container doesn't understand the encoding used to upload files and therefore can't pick the session ID from the HTTP header.
The usual solution is to use response.encodeURL to make the session available as part of the url rather than having to look in the header.
Dave
Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
Thanks for the reply, but I'm not so understand about the reply, can you explain more details?
In my jsp, I'm using out.println to print out the file url for user to click and download. The following is my code in jsp:
out.println("<a href=servlet/download.downloadServlet?attachmentId=" +getAttachId() + "&filename="+URLEncoder.encode(getFName())+">" + getFName() + "</a>");

Tried to use response.encodeURL too, but i still have the same error..
String encodedurl = "servlet/download.downloadServlet?attachmentId=" +getAttachId() + "&filename="+getFName());
out.println("<a href="+response.encodeURL(encodedurl)+">"+ getFName() + "</a>");
Anything that i have missed out???
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Is the problem during the download? I though it would be more likely to show up during a file upload...
Conie Ooi
Ranch Hand

Joined: Jun 09, 2002
Posts: 31
Yes, the problem is after the file is downloaded. The file content is ok, it's just I can't visit to the other page anymore except if I refresh the page..
Any idea how to solve?
 
jQuery in Action, 2nd edition
 
subject: Access denied after file downloading