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.
When you post, look below the box where you are typing and you'll see there are some checkboxes. Since you want to type HTML, you'll want to check the "Disable HTML in this message" checkbox. If you don't, then the forum software will attempt to evaluate the HTML you entered rather than just echoing it.