Wrox Programmer Forums
|
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Struts section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 15th, 2007, 12:09 AM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nishi_gupta
Default Struts+JSP

sample code to provide a link to download an application,on clicking the link some file should be downloaded.
I am making a webapplication which is to be used on mobile devices and i have to download an apllication from this webapplication ,what tag or code should be used in Struts??? please reply soon

 
Old October 15th, 2007, 07:48 AM
Friend of Wrox
 
Join Date: Mar 2007
Posts: 373
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can try by calling a servlet or jsp in that hyperlink or onclick of a button, and in that servlet/jsp set the content type [response.setContentType()] to the appropriate MIME type and the second thing you need to set is "content-disposition" header, see the bellow example

response.setHeader("Content-disposition","attachment; filename=fileName");

after setting these two values open the stream to the file and send all the bytes to the ourupt stream which you can get by response.getOutputStream()



- Rakesh
 
Old October 16th, 2007, 02:58 AM
Registered User
 
Join Date: Oct 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to nishi_gupta
Default

hello rakesh
thanks for ur reply,i have already made a link and written a download action class and struts-config changes.
but its giving servletexception error
<action path="/downloadMyCABFile" type="org.apache.struts.actions.DownloadAction" parameter="/resources/SmartDeviceCab1.CAB"/>

or else if i write
<action path="/downloadMyCABFile" type="
/strutsExample/ExampleFileDownload" parameter="/resources/SmartDeviceCab1.CAB"/>

then it is giving File notFoundException error









Similar Threads
Thread Thread Starter Forum Replies Last Post
Struts Error while loading a JSP page viswasundar Struts 0 May 2nd, 2007 10:55 AM
how to get linkname from jsp to struts action clas mona_1dec Struts 2 May 2nd, 2007 01:04 AM
displaying images in jsp using struts vijayalexander JSP Basics 0 November 6th, 2006 09:46 AM
struts with jsp...exception ... shunmugag Struts 0 September 16th, 2006 03:08 AM
How to display values in a struts jsp by directly naveenkumarg1 Forum and Wrox.com Feedback 0 August 1st, 2005 01:57 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.