You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ilan Azbel <ia...@mdio.net> on 2004/11/25 07:29:12 UTC

generating a csv file with no html headers

Hello,

I have a layout that contains one line:
$screen_placeholder

Also, I have a corresponding .vm file that contains the following:
#foreach ( $result in $results )
  $result.getFName(),$result.getLName()
#end

When I request the vm through a browser I get a page with the following
source code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><title></title></head><body>
FName1,LName1FName2,LName2FName3,LName3
</body></html>


This is not what I want. I am looking to generate a very plain csv file with
the following source code:
FName1,LName1
FName2,LName2
FName3,LName3

That is, a file with no html headers, but one that contains some type of
linefeed/carriage return characters to separate the lines.

It is also acceptable for me to get a request from the browser to "save" the
file to disk when the url is requested.

Any ideas on how to achieve my requirements?

Thanks
Ilan







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


Re: generating a csv file with no html headers

Posted by Shinobu Kawai <sh...@gmail.com>.
Hi Ilan,

> I have a layout that contains one line:
> $screen_placeholder
> 
> Also, I have a corresponding .vm file that contains the following:
> #foreach ( $result in $results )
>   $result.getFName(),$result.getLName()
> #end
> 
> When I request the vm through a browser I get a page with the following
> source code:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
> "http://www.w3.org/TR/REC-html40/loose.dtd">
> <html><head><title></title></head><body>
> FName1,LName1FName2,LName2FName3,LName3
> </body></html>

That's odd.  Maybe your browser is putting in all those html tags.

> This is not what I want. I am looking to generate a very plain csv file with
> the following source code:
> FName1,LName1
> FName2,LName2
> FName3,LName3
> 
> That is, a file with no html headers, but one that contains some type of
> linefeed/carriage return characters to separate the lines.
> 
> It is also acceptable for me to get a request from the browser to "save" the
> file to disk when the url is requested.
> 
> Any ideas on how to achieve my requirements?

Try changing the content-type.  It _might_ work.  Also, if you just want
to use Velocity, VelocityViewServlet might be better to do general HTTP
handling.

Best regards,
-- Shinobu Kawai

--
Shinobu Kawai <sh...@gmail.com>


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