• Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to proved name to the downloadable files in jsp coding  RSS feed

 
Gopinath anumalasetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

I wrote a code to download a zip file in jsp, but it is not working as expected, when i execute this following program i am able to download file with "download_all.jsp" name, but now original download file (/tmp/Download_All/1244687508907.Zip). The download_all.jsp is my jsp name which is having the following code. Please can any one help me to fix this.


Here is the code snippet:


 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code should be a servlet, not a JSP. That's the first thing to attend to. Once you have done that, we can look at any additional problems you might be having.
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears you are asking the user to send you the full path for the file to be downloaded. How is the user supposed to know where on the server the download file is located? That's the responsibility of the server, not the client. So it's unsurprising to me that the file isn't found -- I'm assuming that's the problem, but your description of the problem was pretty sparse. You have a stack trace but you didn't post it, for example.
 
Gopinath anumalasetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:This code should be a servlet, not a JSP. That's the first thing to attend to. Once you have done that, we can look at any additional problems you might be having.


Hi Bear,
Thank you for your help. It should be a JSP and more over this code is working fine in my dev server, but not working in other than dev servers. All the servers are Jboss servers with same configuration.
 
Gopinath anumalasetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:It appears you are asking the user to send you the full path for the file to be downloaded. How is the user supposed to know where on the server the download file is located? That's the responsibility of the server, not the client. So it's unsurprising to me that the file isn't found -- I'm assuming that's the problem, but your description of the problem was pretty sparse. You have a stack trace but you didn't post it, for example.


Hi Paul,

Thanks for your comments, It is just a request parameter, that shouldn't mean that customer providing server side file path. Programming level it self, I am passing values from one jsp to other jsp using request parameter. If it is not good i will change my code accordingly.

Coming to print stack trace, while executing the above code i did not see any errors in logs. that code is executing properly, but issue is there(Downloading Downloadall.jsp with anonymous characters) :(
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gopinath anumalasetty wrote:It should be a JSP…

It most absolutely should not! Java scriptlets were obsoleted over 13 years ago. Using them in JSP in 2014 is irresponsible.

If you are serious about your craft, you should not be using discredited and obsolete technology.

Moreover, JSPs are intended to deliver text content -- trying to make them deliver non-text content can run you into all sorts of difficulties, as you are.

You should read this article to understand what JSP is all about.

 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gopinath anumalasetty wrote:Thanks for your comments, It is just a request parameter, that shouldn't mean that customer providing server side file path. Programming level it self, I am passing values from one jsp to other jsp using request parameter.


It's "just" a request parameter? You do know where request parameters come from, don't you? They come from the client. And it's quite obvious from your code that you're using the value of that parameter as a file path. And you do know where your servlet and JSP code run, don't you? They run on the server. So yes, what you posted absolutely does mean that the client is providing the server-side file path.
 
Gopinath anumalasetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
Gopinath anumalasetty wrote:It should be a JSP…

It most absolutely should not! Java scriptlets ....


Yes Bear, I agree with you, but I am using this code in CMS frame work, I need to do a lot of work to do wright a Servlet for this task. So please give any idea to accomplish this task.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, your framework allows you to use JSP but not servlets?
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before you start any programming, servlet or JSP, you have to fix your broken design. A design where the client specifies the server directory where a file is to be downloaded from is just not practical. Nor is it secure. It's up to the server to decide where the downloads are to come from, and it would even be preferable for the server to provide a page of links to the available downloads, rather than making the client guess at the names of files available.

 
Gopinath anumalasetty
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:So, your framework allows you to use JSP but not servlets?


JSP would be the better option . Is there any way.. but as mentioned earlier it is working fine in one server...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!