Setting File Name in response
Hi,
On server side I read the (Pdf) file and then stream the file content thru response object so that this pdf file opens in browser using Adobe reader. This works just fine.
And right now, if user wants to save this file in browser, complete jsp url appears as file name in save as dialog box.
For eg.:
If my jsp has stream the pdf file from this url
http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf
then
when user tries to save this file, browser save as dialog displays file name as "http://www.xy.com/jsp/displayFileJsp?f=xyz.pdf"
But I want user should download that file name with specific file name like xyz.pdf.
I tried to set the content type
response.setHeader("Content-Disposition", " filename=xyz.pdf" );
But it didn't work.
any suggestions ?
rk
i have created a zip file and i have to make it downloadable i.e. pop-up box should be invoked. my code is
try {
outFilename = "D:\\Product.zip";
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
for (int i=0; i<filenames.length; i++) {
FileInputStream in = new FileInputStream(filenames);
out.putNextEntry(new ZipEntry(filenames[i]));
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
out.closeEntry();
in.close();
out.close();
catch (IOException e)
e.printStackTrace();
String d1file = outFilename;
File f1 = new File (d1file);
response.setContentType ("text/plain");
response.setHeader("Content-Disposition", "attachment;filename=\"" + d1file + "\"");
try {
InputStream in = new FileInputStream(f1);
ServletOutputStream outs = response.getOutputStream();
int bit = 256;
while ((bit) >= 0)
bit = in.read();
outs.write(bit);
outs.flush();
outs.close();
in.close();
catch (IOException ioe)
ioe.printStackTrace(System.out);
it is creating zip file and placing it at D:\\ . I want to invoke download "Save As" pop up box, which is not appearing here! what should I do?
Similar Messages
-
Setting file name for a downloaded file
I've set up a file download using code I've gleaned from jsf forums. However, the file name is not being set correctly. When the user downloads File.doc, it shows up as downloadPage.jsf. Am I setting the header correctly?
public class VendorInfoBean extends AbstractViewController {
public VendorInfoBean() {
public String downloadVendorApp() {
ExternalContext context = getExternalContext();
String path = context.getInitParameter("externalFiles");
String filename = "Vendor_Application_e_Form.doc";
String fullFileName = path + filename;
File file = new File(fullFileName);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");
response.setContentLength((int) file.length());
response.setContentType("application/msword");
try {
FileInputStream in = new FileInputStream(file);
OutputStream out = response.getOutputStream();
// Copy the contents of the file to the output stream
byte[] buf = new byte[1024];
int count;
while ((count = in.read(buf)) >= 0) {
out.write(buf, 0, count);
in.close();
//out.write(bytes);
out.flush();
out.close();
FacesContext.getCurrentInstance().responseComplete();
} catch (IOException ex) {
ex.printStackTrace();
return null;
}StringBuffer sbFilename = new StringBuffer();
sbFilename.append("adeem");
sbFilename.append(".doc");
StringBuffer sbContentDispValue = new StringBuffer();
sbContentDispValue.append("attachment");
sbContentDispValue.append("; filename=");
sbContentDispValue.append(sbFilename);
HttpServletResponse response = (HttpServletResponse) context.getResponse();
response.setHeader("Content-Disposition", sbContentDispValue.toString());
i think this will work .. if not let me know i will give some code that will work for u then ... -
Chain interfaces to set file name in sender channel dynamically
Hi,
I have a requirement to use the Seeburger SFTP adapter to import a file from an external server to an SAP ECC system.
The adapter must be Seeburger as the protocol has to be SFTP, not FTPS as with the File adapter.
Although I can set a wildcard selection, I really want to poll for specific filenames with predetermined naming criteria.
The sender SFTP communication channel doesn't provide any options to specify dynamic attributes but I wonder if I can link several interfaces together, please can you confirm if the following process would work conceptually:
1) SAP ECC program runs and determines the fixed filename that I wish to import (e.g. file_abc123.xml).
2) SAP ECC program calls an outbound proxy with a mapping to set the relevant parameter in dynamic configuration ('http://seeburger.com/xi' is the namepsace, 'dtSubject' is the parameter name for the filename of the SFTP adapter). Besides mapping I think the Seeburger attribute mapper module could also be used to set this value.
3) The outbound proxy is configured on the receiver side to call an SFTP sender channel (with a dummy/blank payload as we're only calling the interface to allow settng of the filename to take place) which links to an inbound service interface on the SAP ECC receiver side.
I don't know whether chaining of service interfaces in this fashion (receiving interface also being a sender) is a viable approach or whether there are any alternatives.
Thanks in advance,
AlanHi Alan,
Are the specific file names that you are polling for going to be changing or will they be fixed? Are each of the unique names going to be processed using the same interface? If so then I would just create multiple SFTP sender channels that poll at different intervals but use the same mappings, etc.
Regards,
Ryan Crosby -
How to set file name and destination folder without user interaction
how can I set the file name and destination folder to generate a pdf file like "c:\myfolder\document.pdf" in this folder automatically.
Is there a tag in .joboptions ?
Goal: User click print button. In the background a pdf will be generated in e.g. "C:\myfolder\document.pdf".
that`s it.
I know that the query dialog for save as can be turned off. But the file name depends on the application.
Thanks for your help.
TKHello,
Please post this in PI forums
Regards, Anil -
Using TCS 5, RH11, FM12, all patched up, if I set a marker, such as "Filename" in FrameMaker, can RoboHelp use the contents of that marker to set the file name of the HTML file it creates? How? Thoughts?
Cheers,
SeanHi,
Thanks for working with me on this. I appreciate your help. The last time I used RoboHelp was when Blue Sky owned it, at the original version 6. I see it has aged logically.
Cheers,
Sean -
Setting File Name inside ABAP mapping
Hello All,
We have a requirement where we need to send the IDOC in a flat file format to the destination system which we are doing inside an ABAP mapping. Now we need to set the file name depending on a particular field in the IDOC. For this we need to use the DynamicConfigurationKey class inside our ABAP mapping.
Can anyone throw some light how to access these Adapter-Specific Attributes inside ABAP mapping?
Thanks
Abinashguess this is the one
Re: Abap mapping and variable substitution in File adapter -
Need help in setting file name with special characters in attachment
Hi
We have a requirement where we need to set the file name that contains special characters (like Russian) and send mauil using Java mail.
If we set the file name as such, the attachment in the email contains garbled filename
Can you pl let me know how to resolve this?
We should use the file name as attachment name and this will have say special characters. The receiver who gets the mail should get with the correct attachment name
One important point.. the attachments are opened from MS outlook.
Thanks and regards
Ram
Edited by: 884910 on 13 Sep, 2011 5:00 AMRead the FAQ carefully. You don't need to call encodeText unless you're using a really
old version of JavaMail.
And, it depends on whether the mail reader you're using is handling encoded parameters
according to the (new) MIME standard, or according to the (old) non-standard hack.
Sadly, without knowing what mail reader the recipient is using, it's impossible to use
encoded filenames that will work everywhere. -
Set file name as a variable. Then use it to name a folder
I'm making a workflow that I want to get the selected file, then create a new folder using that file's name. I made a workflow as follows:
Get selected Finder Item (In this case a JPG image)
Set Value of Variable
New Folder (dragging the variable from 'Set Value of Variable')
But running this workflow it adds the path of the file to the new folders name, as well as the file's name (e.g. instead of the folder being called 'Photo1' it's called '/Users/Jono/Desktop/Photo1.jpg').
Does anybody know how I could get it to just the file name (preferably without the extension) instead of prefixing it with the path?The New Folder action uses the specified text for the file name. The following Run AppleScript action will return just the names of the Finder Items passed to it:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFDDFF;
overflow: auto;"
title="this text can be pasted into an Automator 'Run AppleScript' action">
on run {input, parameters}
get a name from a file path
input: a list of Finder Items (aliases)
output: a list of names
set output to {}
repeat with AnItem in the input -- step through each item in the input
set {name:TheName, name extension:TheExtension} to (info for AnItem)
if TheExtension is missing value then set TheExtension to ""
set end of output to (text 1 thru -((count TheExtension) + 2) of TheName) -- just the name part
end repeat
return the output -- pass the result(s) to the next action
end run
</pre> -
How to get set file name for MessageFileUploadBean in Advanced Table
Hello Everyone.
I have a MessageFileUpload item in a advanced table. My requirement is to show file names instead of view when user uploads files. I know how to do this if the item is not inside advancedtable (by using uploadBean.setAttributeValue(DOWNLOAD_FILE_NAME,displayNameBoundValue).
But how to get the different ID's when inside a advanced table?
Thanks
Sunnytry setting a transient view attribute to this message file upload, if you iterate through vo, I hope you can just get the path user browses.
Regards
Shobht S -
How to set file name in a JFileChooser to be some default String?
Dear all,
I am tring to make my JFileChooser more user-friendly, so every time that a JFileChooser show up, I would like to fill the file name with some default String, instead of just leaving them blank.
Does anybody know how to do this?
Many Thanks!look up the set...() methods of the JFileChooser api docs
-
I'm trying to write a script to rename all of the files in a folder using regular expressions. I can tell when I run it that I am correctly changing the names of the files the way I want; the problem comes when I try to set the name. I get this error:
error "Finder got an error: Can’t set file \"[first file]\" to \"[new name]\"." number -10006 from file "[first file]"
I've tried looking on over a dozen forums and tutorial sites, and as far as I can tell, I'm doing the right thing! Can someone please help?
tell application "Finder"
set f to "Example:"
set fileNames to name of files of folder f
end tell
repeat with aFile in fileNames
tell application "System Events"
considering case
set episode to aFile
set episode to my switchText(episode, "[", "- ")
set episode to my switchText(episode, "]", " -")
set episode to my switchText(episode, "x0", "0")
set episode to my switchText(episode, "x1", "1")
set episode to my switchText(episode, "x2", "2")
end considering
end tell
tell application "Finder"
set fileName to (a reference to file aFile)
set name of fileName to episode <<------------------error
end tell
end repeat
to switchText(theText, SearchString, ReplaceString)
set OldDelims to AppleScript's AppleScript's text item delimiters
set AppleScript's AppleScript's text item delimiters to SearchString
set newText to text items of theText
set AppleScript's AppleScript's text item delimiters to ReplaceString
set newText to newText as text
set AppleScript's AppleScript's text item delimiters to OldDelims
return newText
end switchTextTry replacing
tell application "Finder"
set fileName to (a reference to file aFile)
set name of fileName to episode
end tell
with
tell application "Finder"
set name of file aFile of folder f to episode
end tell -
Record set file names not appearing ?
Could anyone tell me why the file names for the record sets that I'm creating don't show up. The "lightning bolts" representing the data show up under the rs name and it appears within the code, but the file names are not next to the bolts as expected ?
Thank you,
Fred...Hello PZ,
Thanks for jumping in and trying to help. Sorry for my ignorance when
it comes to this as I am just diving into the world of data bases
using php and mysql. I believe I was referring to the created "table
set name" and the "fields" within them (see bottom) . In the bindings
panel the lightning bolts appear under the created table set, but the
name of the table set is not appearing and these highlighted file
names "fields" that should be next the lightning bolts to identify
them are not appearing. These names , and so on
appear in the code but not in the bindings panel next to the lightning
bolts to help me identify which one I am choosing .
The php page is working the way I want but I have to go through the
process of elimination to figure out which "field" e.g
I'm choosing when placing them in a table in my dreamweaver page. I
hope I am explaining myself properly and thank you very much again for
your efforts.
Fred...
Here is the code I'm talking about and a picture of the database I'm
getting them from.
Year built
Floors
Address
Elevator
Doorman
Gym
Contact
Pets
Parking
Fireplace
Phone:
Email:
Description:
buildingID propName address neighborhood phone email floors do orman
elevator pets yearBuilt propPic inParking outParking fireplace
description gym
14 BC670 280 East 2nd Street Downtown 2125559876 [email protected]
6 0 0 0 1977 BC670.jpg 0 0 0 Located between Avenues C and D at
Houston Street ... 0 -
I'm looking for an action that will take files as input and output the file names as text. Does anyone know of an included or free action to do this?
Message was edited by: KatieS1975You can use AppleScript's text item delimiters to add some text between the (text) items when converting the input list to text:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
on run {input, parameters} -- convert the input list to text using the specified delimiter
try
set tempTID to AppleScript's text item delimiters -- save the current delimiter
set AppleScript's text item delimiters to return -- change the delimiting text as desired
set the output to the input as text
set AppleScript's text item delimiters to tempTID
on error errorMessage number errorNumber -- restore the original delimiter before passing on the error
set AppleScript's text item delimiters to tempTID
error errMessage number errorNumber
end try
return the output
end run
</pre> -
Loop Page Style Sheet to set file name.
I am exporting pages to jpgs and pngs using a script that pulls the name from an applied style sheet.
http://forums.adobe.com/message/5913479#5913479
the above works perfectly if I only want to specify one style sheet as the file name.
the challenge may need to use different style sheets on each page to create the name.
I am not sure how to loop through each page and grab the style in play.
or if I need to loop at all.
This is where I am...
function MakePNGfile()
for(var myCounter = 0; myCounter < myDoc.pages.length; myCounter++)
if (myDoc.pages.item(myCounter).appliedSection.name != "")
myDoc.pages.item(myCounter).appliedSection.name = "";
var myStyle1 = "sheetlabel-text";
var myStyle2 = "sheetlabel-text-2";
var myParagraphs = myDoc.pages.item(0).textFrames.item(0).parentStory.paragraphs;
var myPageName = myDoc.pages.item(myCounter).name;
var myPNGPrefix = "";
for( i = 0; i < myParagraphs.length; i++)
var paragraph = myParagraphs.item(i);
if (paragraph = myStyle1)
(myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text"), myDoc.pages.item(myCounter))+ '-0' + myPageName)
else
(myPNGPrefix = getParagraphContent(myDoc.paragraphStyles.item("sheetlabel-text-2"), myDoc.pages.item(myCounter))+ '-0' + myPageName)
Thanks for your help!Good to hear .
Find attached the next version. You can now insert in 'paraStyleNames' as many style names as you want. The script will check from left to right, if there is one found on the page. If this is true, the script will ignore the other styles.
Removing leading zero should work now.
Maybe one problem: If one page contains no style, this page will be exported nevertheless with it’s correct page number, but with the founded text of the previous page. If this can never happen, we are done and you should mark the answer as correct. If this is a real problem for you, please let me know, what should happen in this case and I will try to fix that too.
// Export pages as JPG with additional info by Kai Rübsamen
// http://forums.adobe.com/message/6326425#6326425
main ();
function main() {
var curDoc = app.activeDocument;
// Array of paragraph Style names
var paraStyleNames = ["h1", "h2"]; // insert here your para names !
var missingParaStyles = [];
// check, if the styles are valid
for ( var p = 0; p < paraStyleNames.length; p++ ) {
var curName = paraStyleNames[p];
// if the style is missing, push it to the array
if ( !curDoc.paragraphStyles.itemByName(curName).isValid ) {
missingParaStyles.push( curName );
// if some styles are missing, give an alert
var nMiss = missingParaStyles.length;
if ( nMiss > 0 ) {
var display = missingParaStyles.join( "\r" );
alert ( "Missing para(s):\r" + display );
exit();
// loop through all pages
for ( var i = 0; i < curDoc.pages.length; i++ ) {
// the current page
var curPage = curDoc.pages[i];
// the current pages name
var pName = curPage.name;
// controls the loop
var controller = true;
// all paragraphs on the current page
var allPageParas = curPage.textFrames.everyItem().paragraphs.everyItem().getElements();
// loop through all paragraphs and check, if one has the para style applied
for ( var p = 0; p < allPageParas.length; p++ ) {
if ( !controller ) break;
// the current para
var curPara = allPageParas[p];
// loop through the styles
for ( var n = 0; n < paraStyleNames.length; n++ ) {
if ( curPara.appliedParagraphStyle.name == paraStyleNames[n] ) {
var paraContents = curPara.contents;
var paraString = "-" + paraContents.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase();
controller = false;
break;
} // end if
} // end for paraStyleNames
} // end for allPageParas
//~ var folderPath = "~/-client/JOYS - Just Organize Your Stuff/-Art/-art-book-kindle/";
var folderPath = Folder.desktop;
if ( pName < 10 ) {
var appendix = "-0" + pName + paraString;
else {
var appendix = "-" + pName + paraString;
var filePath = folderPath + "/" + curDoc.name.replace(/\.indd$/,"") + appendix + ".jpg";
var myFile = File( filePath );
with ( app.jpegExportPreferences ) {
jpegQuality = JPEGOptionsQuality.high; // low medium high maximum
exportResolution = 72;
jpegExportRange = ExportRangeOrAllPages.exportRange;
pageString = pName;
curDoc.exportFile( ExportFormat.jpg, myFile, false );
} // end for pages
} // end main
–Kai -
Setting file name of captured file in DVRcast application
I've looked through the scripts in the scripts/ directory, but haven't seen anything obvious.
I would like to be able to specify the file name to capture the stream to. At present, the capture file is always named the same as the stream, which means if I stream for a bit, stop, then restart, the originally captured file gets overwritten. I'd like to be able to incorporate something, i.e. the stream start time, into the capture file name.
Pointers to where I can do that?Good that you found the previous issue solved
For me, the best always is to go for mp4 format irrespective of the encodings. MP4 can support VP6/H264/MP3 and AAC.
And for FMS to record a file in mp4/f4v format, you need to prefix a mp4: to the stream name while publishing and/or recording. This "mp4:" mentions the FMS to load the mp4 module and all the stream actions are now under its control.
It is a general usage that for VP6-MP3 we go for FLV format (for which no prefix is needed) for H264/AAC , we go for MP4. But as I said, MP4 can serve all your purposes.
There are no APIs as such on FMS that I can think of , to do this. All you need to do is to add the prefix or not. It can be controlled either through a good client logic or , can be totally eliminated by having a singular structure.
Hope this also helps you for your work , Thank you !
Maybe you are looking for
-
Error in BW project creation in HANA
Hello, experts! I faced an issue with creation the BW project in HANA I have already installed SAP HANA Studio, established connection to my server with HANA. Also I installed all necessary plugins: - Add-ons of ABAP development tools for SAP HANA (D
-
Hi, I am new to Apple. On my PC I had Adobe Photoshop CS2. Does anyone know if I can find that for my apple? In the later versions they do not have the tool I use. Thank you.
-
Windows 7 want do format my N9 ?!?!?
Hi i got a new N9 (because the old one broke down) I tried to copy my mp3 collection to the phone... But if I connet the phone via USB to my notebook (win 7 prof) and tell the phone to behave as mass storage, windows ask me if i want to format the ne
-
My Phone Won't Charge Or Connect To iTunes?
Uhm... my phone died at school today, and I just got home and tried to charge it on my mac. Well, iTunes opened as usual, and it said: "iTunes connot connect to the iPhone, "my iphone" because it is locked with a passcode. You must enter your passcod
-
Hello ,I have to cancel my Adobe account
Hello ,I have to cancel my Adobe account ,it cost my money every month , so how can i cancel it. Thank you