0

I am already Integrated Spring core with JSF and Hibernate to develop my web application. I am developing a file download functionality which let's users to download a pdf files from one of the shared drive on our network.I want to Use Spring MVC to implement this file download functionality.In this context do i need still need to define DispatcherServlet and URLHandlerMapping in Web.xml.What other ways I can implement this file download functionality in java without any complication.Please provide any examples of file download in java.

Azzabi Haythem
  • 2,318
  • 7
  • 26
  • 32
mdp
  • 815
  • 4
  • 17
  • 32
  • 1
    Any particular reason why you want to use Spring MVC just for this one requirement? – Ravi Kadaboina Sep 10 '12 at 03:18
  • Not any particular Reason....I found some online examples with Spring MVC file download functionality.Please suggest if there are any other ways to implement it. – mdp Sep 10 '12 at 04:05
  • You say you've integrated spring core to JSF, do you mean mojarra? If you don't mind the added dependency, Primefaces has a straightforward implementation of [File Download Functionality, example here](http://www.primefaces.org/showcase/ui/fileDownload.jsf). You don't need Spring MVC for just that – kolossus Sep 10 '12 at 04:23
  • @kolossus.... surprisingly I am Using primefaces along apache my faces implementation of JSF.I already implemented it through primefaces but when i click on Download button nothing is happening in the backend.As shown in primefaces example I created a instance for controller but the method in is not working.my question is do i need to write as many as tags for multiple files? Cause i need to list all the files on the screen which are in one of our shared drives. – mdp Sep 10 '12 at 04:30

2 Answers2

0

With a Servlet it's very easy. You have to generate a link with an id (or encrypted id if you need) After, flush your file into HttpServletResponse. The header is very important also.

Cheers

YoelBen
  • 113
  • 8
0

You can have a REST service which has a implementation of retriveing logic. In this way it can be reused.

WPrathamesh
  • 175
  • 1
  • 1
  • 5