Kans, I have found that the easiest way to do this is to simply alias 
your jsp or servlet to somename.csv.  Then, if you just return a file 
with comma separated values, your IE will open MSExcel as an OLE thingy. 
 Netscape will may prompt you.  So, like this in your web.xml:

    <servlet>
        <servlet-name>Sql2Csv</servlet-name>
        <jsp-file>/forms/sql2csv.jsp</jsp-file>
    </servlet>
    <servlet-mapping>
        <servlet-name>Sql2Csv</servlet-name>
        <url-pattern>/forms/sql2csv.csv</url-pattern>
    </servlet-mapping>


When IE sees that the file type of .csv it loads the results into Excel. 
 So it *only* works if your URL ends with .csv, so you must POST if 
parameters are needed.  You just need to write the csv to the stream (in 
jsp out.print()).  To help Netscape you can add content type like so:

<%@ contentType="application/vnd.ms-excel"
%>

There are fancier ways to do this with XML as the so called pet shop 
examples show.  However, I like the KISS principle.  Hope that helps, BenG.

Kannaiyan P wrote:

>Hi
>  I m using jrun4. i have question for you you know the finance.yahoo.com . 
>if you open any ticker for company you can see the daily stock value of the 
>particular company based on period. at same time if you want to download the 
>information you can download the data using excel file. so when user access 
>my web site i want to give option to download the data dynamically. i don't 
>know how to do that . i m using java , jsp, oracle database. please if any 
>body know the solution or code please share the information . that would 
>very helpful for me
>
>Thanks
>Kans
>
>
>
>
>
______________________________________________________________________
Get the JRun Web Application Construction Kit - the only book written specifically for 
JRun developers.
http://www.amazon.com/exec/obidos/ASIN/0789726009/houseoffusion
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to