2

I've been trying to implement an action which allows the user to download a file with a specific filename. This filename is set by passing the action a parameter through struts.xml this way:

<result name="success" type="stream">
            <param name="contentType">application/octet-stream</param>
            <param name="inputName">input_document</param>
            <param name="contentDisposition">attachment;filename=foo.bar</param>
            <param name="bufferSize">1024</param>
</result>

I have omitted the rest of the code as I just want to focus on this:

<param name="contentDisposition">attachment;filename=foo.bar</param>

That way it works perfectly and lets you download the foo file with .bar extension.

So here's the deal, I was curious to know wether if is it possible to retrieve the extension from a properties file and pass it through the parameter, for example, like this:

<param name="contentDisposition">attachment;filename=foo%{+ getText("EXTENSION_KEY_IN_PROPERTIES_FILE")}</param>

I know that getText("...") won't work but I just want you to understand what I'm searching for.

I'm currently working with some properties files for global parameters and localization stuff so it would be great if I could retrieve this file extension from one of them.

1 Answer 1

1

It should work if your action implements TextProvider

<param name="contentDisposition">attachment;filename=foo${getText('EXTENSION_KEY_IN_PROPERTIES_FILE')}</param>
Sign up to request clarification or add additional context in comments.

3 Comments

Well it seems the issue was I didn't add the properties file to the project resources properly... worked like a charm when I did. @Roman What does that <![CDATA[]> stands for ?? Thank you :)
It's used with the text that uses special characters omitted by xml parser when parsed a document. I removed them from the answer.
Oh, Ok, I'll accept your answer as you point out well that TextProvider must be implemented by the action. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.