[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Dowloading Vcard from Web Page



Hi,

 

Attached is the servlet file, modify the vcard string as per your requirement & compile to java class file.

 

You will need a web application container like Tomcat (http://jakarta.apache.org/tomcat/tomcat-5.5-doc/).

Put the servlet class file in $TOMCAT_HOME/webapps/<SomeProject>/WEB_INF/classes/ directory

 

Add following to the web.xml (present in WEB-INF directory)

<!-- ExportVCard -->

      <servlet>

          <servlet-name>ExportVCard</servlet-name>

          <servlet-class>ExportVCard</servlet-class>

      </servlet>

    <servlet-mapping>

            <servlet-name>ExportVCard</servlet-name>

          <url-pattern>/ExportVCard</url-pattern>

      </servlet-mapping>

 

 

In your web page call as follows:

<a href="" >Download VCard</a>

 

This will download the .vcf file and you can open it or save to some location.

 

Regards

Ajay Naphade

Project Leader - R&D
ajaynaphade@xxxxxxxxxxxxxxx

 


From: Matthew Mandell [mailto:savewestport@xxxxxxxxxx]
Sent: Wednesday, September 28, 2005 7:02 PM
To: ajaynaphade@xxxxxxxxxxxxxxx
Subject: Re: Dowloading Vcard from Web Page

 

Could you send me an example of how to do this servlet and where to place it on the server and how to call it, I have not programmed in years. I appreciate the help.

Thanks


Ajay Naphade wrote:

 
I am not sure about existence _javascript_ which could do this.
 
But following method is tested by me:
 
Write a servlet with its doPost method having following:
 
//get outputstream
OutputStream outputStream = response.getOutputStream();
 
//set MIME type for http header, extension vcf //content type text/plain
response.setContentType("text/plain");
String fileName = "attachment; filename="myvcard.vcf";
response.setHeader("content-disposition",fileName);
        
:
:
//write the vcard string to the outputstream
outputStream.write(vcardString); outputStream.close();
 
In your web page, <a href="" Vcard</a>
(Remember to configure the web.xml for the servlet class name.)
 
Regards
Ajay Naphade
Project Leader - R&D
ajaynaphade@xxxxxxxxxxxxxxx
 
-----Original Message-----
From: Matthew Mandell [mailto:savewestport@xxxxxxxxxx] 
Sent: Wednesday, September 28, 2005 5:04 PM
To: ajaynaphade@xxxxxxxxxxxxxxx
Subject: Re: Dowloading Vcard from Web Page
 
Thanks, but how do you do that? Are the any stock scripts out there that 
do it?
 
Matthew
 
Ajay Naphade wrote:
 
  
Hi,
 
Straight href will do but you should call a java program, which will set
    
the
  
header "Content-disposition" and write the file to output stream.
 
Regards,
Ajay Naphade
 
-----Original Message-----
From: owner-imc-vcard@xxxxxxxxxxxx [mailto:owner-imc-vcard@xxxxxxxxxxxx] On
Behalf Of Matthew Mandell
Sent: Tuesday, September 27, 2005 7:00 PM
To: imc-vcard@xxxxxxx
Subject: Dowloading Vcard from Web Page
 
 
I am trying to put Vcards on a web page for downloading.  The link is a 
straight "A Href="" The browsers are treating it as a flat text file and 
showing the info rather than asking to download the file.
 
Is there a _javascript_ or some way to trick the browser to ask it to 
download rather than should the text?
 
thanks
 
 
 
 
.
 
 
 
    
 
 
 
 
 
  

Attachment: ExportVCard.java
Description: Binary data