You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Collings <jl...@gmail.com> on 2009/06/09 22:13:43 UTC

Save web page as pageName.doc

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


Re: Save web page as pageName.doc

Posted by Wes Wannemacher <we...@wantii.com>.
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 <ne...@yahoo.com> 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


Re: Save web page as pageName.doc

Posted by Dave Newton <ne...@yahoo.com>.
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


Re: Save web page as pageName.doc

Posted by Jim Kiley <jh...@summa-tech.com>.
On Tue, Jun 9, 2009 at 6:25 PM, Dave Newton <ne...@yahoo.com> 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

Re: Save web page as pageName.doc

Posted by Dave Newton <ne...@yahoo.com>.
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


Re: Save web page as pageName.doc

Posted by Jim Kiley <jh...@summa-tech.com>.
On Tue, Jun 9, 2009 at 4:31 PM, Dave Newton <ne...@yahoo.com> 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

Re: Save web page as pageName.doc

Posted by Dave Newton <ne...@yahoo.com>.
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