Grokbase Groups Struts user June 2009
FAQ
It's a report and the requirement I'm trying to satisfy is that you
have to be able to save it as a MS Word *.doc file. What I've
discovered is that you can take a stand-alone html file (i.e. no
external files like images or CSS etc. ) change the file extension
from *.html to *.doc and double clicking opens it in Word without any
trouble.

So... question is how do I get Struts 2 to cooperate with this
ideology? I'm thinking, click on a link to some kind of pseudonym for
the same report and then test in the action that prepares the report
to see where the user is coming from. I suppose I could differentiate
this by setting a parameter in the urls in question. After I know
where they are coming from, I can choose to set these headers:

Content-Type to "application/msword"
and
Content-Disposition to "filename=someFileName.doc"

Hmmm.... that last one may solve my file name problem.

Anyway, I'm guessing here. I've never done this before. Anybody see
anything wrong with this? Does Struts provide an easier way or some
helpful tools that I should know about?


Jim C.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Search Discussions

  • Dave Newton at Jun 9, 2009 at 8:31 pm

    Jim Collings wrote:
    It's a report and the requirement I'm trying to satisfy is that you
    have to be able to save it as a MS Word *.doc file. What I've
    discovered is that you can take a stand-alone html file (i.e. no
    external files like images or CSS etc. ) change the file extension
    from *.html to *.doc and double clicking opens it in Word without any
    trouble.
    Only if your machine is configured to open up HTML files in Word, which
    strikes me as completely bizarre.
    Anyway, I'm guessing here. I've never done this before. Anybody see
    anything wrong with this? Does Struts provide an easier way or some
    helpful tools that I should know about?
    The REST plugin provides for trivial binding of URL extensions to
    content types, but you're probably want to actually write a Word file
    rather than relying on somebody's broken setup.

    Dave

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org
  • Jim Kiley at Jun 9, 2009 at 9:54 pm

    On Tue, Jun 9, 2009 at 4:31 PM, Dave Newton wrote:

    Jim Collings wrote:
    It's a report and the requirement I'm trying to satisfy is that you
    have to be able to save it as a MS Word *.doc file. What I've
    discovered is that you can take a stand-alone html file (i.e. no
    external files like images or CSS etc. ) change the file extension
    from *.html to *.doc and double clicking opens it in Word without any
    trouble.
    Only if your machine is configured to open up HTML files in Word, which
    strikes me as completely bizarre.
    Just for fun I just tried it -- made a trivial HTML file, named it
    "foo.doc," and double-clicked, and it did open in Word. Properly formatted
    and so on too. Word is happy to open HTML files. It loves you and it wants
    you to be happy.

    jk
  • Dave Newton at Jun 9, 2009 at 10:25 pm

    Jim Kiley wrote:
    Just for fun I just tried it -- made a trivial HTML file, named it
    "foo.doc," and double-clicked, and it did open in Word. Properly formatted
    and so on too. Word is happy to open HTML files. It loves you and it wants
    you to be happy.
    On *your* machine, perhaps. On all my Windows machines an HTML file
    will, by default, open in Firefox, or on a work machine I have no
    control over, IE.

    This is reasonable behavior: it's a web page, not a word processor
    document. Unless you are controlling deployment, you don't have control
    over what a user's machine will open an HTML file in on a double-click.

    Dave

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org
  • Jim Kiley at Jun 9, 2009 at 11:14 pm

    On Tue, Jun 9, 2009 at 6:25 PM, Dave Newton wrote:

    Jim Kiley wrote:
    Just for fun I just tried it -- made a trivial HTML file, named it
    "foo.doc," and double-clicked, and it did open in Word. Properly
    formatted
    and so on too. Word is happy to open HTML files. It loves you and it
    wants
    you to be happy.
    On *your* machine, perhaps. On all my Windows machines an HTML file will,
    by default, open in Firefox, or on a work machine I have no control over,
    IE.

    That surprises me, since I had always assumed that Windows based the
    application of choice on the file extension. I wonder what other guidance
    is being used. Content-type?

    This is reasonable behavior: it's a web page, not a word processor
    document. Unless you are controlling deployment, you don't have control over
    what a user's machine will open an HTML file in on a double-click.

    This I totally agree with.

    --
    Jim Kiley
    Senior Technical Consultant | Summa
    [p] 412.258.3346
    http://www.summa-tech.com
  • Dave Newton at Jun 10, 2009 at 12:21 am

    Jim Kiley wrote:
    That surprises me, since I had always assumed that Windows based the
    application of choice on the file extension. I wonder what other guidance
    is being used. Content-type?
    AFAIK it's extension in both XP and Vista. Can't check the XP machine
    now, but my Vista machine configures this via Control Panel -> Default
    Programs; .htm and .html are configured for Firefox, and were IE before
    I installed FF.

    Dave

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org
  • Wes Wannemacher at Jun 10, 2009 at 1:08 am
    Yeah windoze still honors extension, but they have added the ability
    to make multiple associations. However, if memory serves, IE honors
    content-type. So if set it to application/msword or whatever it should
    try to launch a word doc viewer. I noticed an example of "the wrong
    way" recently while downloading a spreadsheet. Content type and file
    extension were both set for excel, but the file was a csv. Excel
    launched though, but warned me that it really wasn't an xls file. I
    would think a similar problem will crop up later if you use html to
    create a word doc. My suggestion is to create and use rtf or docx.
    Both are text based so u should be able to do it with little effort
    and you don't run the risk of looking like you are propagating a
    virus.

    Wes
    On 6/9/09, Dave Newton wrote:
    Jim Kiley wrote:
    That surprises me, since I had always assumed that Windows based the
    application of choice on the file extension. I wonder what other guidance
    is being used. Content-type?
    AFAIK it's extension in both XP and Vista. Can't check the XP machine
    now, but my Vista machine configures this via Control Panel -> Default
    Programs; .htm and .html are configured for Firefox, and were IE before
    I installed FF.

    Dave

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org

    --
    Wes Wannemacher
    Author - Struts 2 In Practice
    Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
    http://www.manning.com/wannemacher

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org
  • Jim Collings at Jun 25, 2009 at 7:06 pm
    This still isn't working. In theory, if I set the meta data as below:

    <meta http-equiv="Content-Disposition" content="inline;
    filename=downloadable-report.doc"/>

    This should explicitly tell the browser what to call the file but the
    file name still comes out as action-name.

    Does anyone have any ideas as to how I can prevent this? Perhaps if I
    move the "downloadable-report.jsp" file to a different location? One
    not used by the convention plugin or Struts 2 or something?


    Jim C.

    ---------------------------------------------------------------------
    To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
    For additional commands, e-mail: user-help@struts.apache.org

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categoriesstruts
postedJun 9, '09 at 8:14p
activeJun 25, '09 at 7:06p
posts8
users4
websitestruts.apache.org
irc#struts

People

Translate

site design / logo © 2022 Grokbase