Greetings,
First of all, I'm not sure whether I should have posted this question in
struts or in
jsp forum as I'm not aware if it is something that can/should be handled with jsp and scriptlet combination, jsp/javascript combination or if struts has a cool tag library that can handle file download. Could you please move the topic to appropriate forum depending on where it'd better be.
My webpage needs to have a button that lets the user download a sample file from the server. And it needs to have a button that lets the user upload such a file with data. The upload part is working fine. It's the download that I'm having trouble with. This is how the upload part is working.
My form has a FormFile type field which is set in the jsp as follows.
My struts-config is as follows.
Relevant part in tiles-defs is as follows.
My form class doesn't need run any grand logic or something to do the upload. It just has the following import.
and has the usual setter for a FormFile type variable as follows.
And my action method invokes this setter. And there is no other logic I need write for the upload to work.
Isn't there something like FormFile that struts already has for the download to also work? Is there a link or a tutorial I could read?
I checked on web for "how to download a file from jsp" and almost everyone uses an
tag and then creates the download.jsp that has a big scriptlet code that creates an output stream. I've tried this. When I click on the link, my page changes. This is not what I want. Plus the downloading does not happen ( but I will resolve this part later ). And the existing jsps don't use grand scriptlets so I am not sure if it's a good practice to embed lot of
Java code within a JSP.
Doesn't struts have some elegant way for the download too?
Sorry if I didn't specify something that is required. I'm very new to the UI components. So I don't know much. Let me know if I need to provide more information.
I'm fine with trying out anything that's available- tutorials, links, books, hints, .. so long as I can get it working in the end.
Thanks.