XSQL servlet cannots set Content-Disposition

XSQLPageRequestImpl does not have a method to set the value of the "Content-Disposition" parameter of the HttpServletResponse.
In the PLSQL Package HTP one can set additional headers of the HttpServletResponse.
Currently, due to the lack of support of XSQLPageRequestImpl, it is not possible to provide proper filename to save e.g. servlet output.
Something like
res.setHeader("Content-disposition","attachment; filename=\""+pathName+"\"")
is needed at serializer level and therefore shall be implemented in XSQLPageRequestImpl or at least accessible from it.

The following code does the job.
import oracle.xml.parser.v2.XMLElement;
import oracle.xml.xsql.XSQLDocumentSerializer;
import org.w3c.dom.*;
import oracle.xml.xsql.XSQLPageRequest;
import oracle.xml.xsql.XSQLServletPageRequest;
import oracle.xml.sql.core.OracleXMLConvert;
import java.io.OutputStream;
import javax.activation.*;
import javax.servlet.http.HttpServletResponse;
public class BLOBSerializer implements XSQLDocumentSerializer {
public BLOBSerializer() { }
public void serialize(Document doc, XSQLPageRequest env) throws java.lang.Throwable {
XMLElement docRoot=(XMLElement)doc.getDocumentElement();
String contentDisp="attachment; filename="+docRoot.valueOf("./filename");
XSQLServletPageRequest xspr=(XSQLServletPageRequest)env;
HttpServletResponse hsp=xspr.getHttpServletResponse();
hsp.setHeader("Content-disposition",contentDisp);
OutputStream out = env.getOutputStream();
env.setContentType(docRoot.valueOf("./request/parameters/doc_type"));
String DocString=docRoot.valueOf("./ROWSET/ROW/DOCUMENT");
byte abyte0[] = oracle.xml.sql.core.OracleXMLConvert.convertHexStringToByte(DocString);
out.write(abyte0, 0, abyte0.length);
out.flush();
out.close();

Similar Messages

  • Bug setting Content-Disposition of response with the July 20th build of Weblogic 6.1

              I am using the July 20th Beta build, weblogic610_bld_127633_sol.bin, running under
              Solaris OS 2.6.
              I have two basic questions:
              1. Why am I seeing the error I describe below.
              2. Will this problem be fixed either by:
              A. A new release of the iisproxy.dll accompanying Weblogic 6.1 GA release on July
              30th (I currently use the iisproxy.dll which accompanied Weblogic 6.0 sp 1).
              B. A fix in the jsp response handling of the application server in the GA release.
              When used with the iisproxy.dll, in Weblogic 6.1 a jsp can not contain code to
              alter the filename in the response it is returning based on a request. This functionality
              worked in both Weblogic 4.5 and Weblogic 6.0 sp2.
              I use the following code to send back a tab seperated value file with a variable
              filename from a jsp page.
              response.setHeader("Content-Disposition", "filename=" + strFileName ".tsv");
              response.setContentType("text/tab-separated-values");
              When hitting Weblogic Server directly, this code works fine in Weblogic 6.1.
              My browser presents me with a download prompt, with a default filename equal to
              the variable filename I am setting in the jsp page.
              When hitting Weblogic Server through iisproxy.dll, iisproxy.dll gets the response
              from the application server, ignores it, then repeatedly resends the request to
              the application server. It gives up after 6 "bad" responses, and returns
              "No backend server available for connection: timed out after 20 seconds.".
              The functionality was perfect with the identical iisproxy.dll used with either
              Weblogic 4.5 or Weblogic 6.0 sp2.
              Things I have already tried:
              I can't find a newer version of the iisproxy.dll than the one that came with Weblogic
              6.0 sp1 (This is the 696 KB one).
              I have confirmed that the exact line of code which breaks the iisproxy.dll is
              the line where you set the filename. The download prompt works fine if you don't
              try to alter the response to set a specific filename.
              I have confirmed that changing the file extension to .jsp while still trying to
              alter the filename fails.
              

    As you said, it could be the WLS6 truststore which doesn't contain the certificate authority. Just check which files are used (cacerts, cacerts.jks,..), and maybe you can find it by checking the option startup : -Dweblogic.security.SSL.trustedCAKeyStore
    It doesn't matter when the exception is triggered (you can do an explicit handshake, or just write in the socket and then wait for an implicit handshake)

  • How to set Content-Disposition to "application/json;"

    Using System.Net.Http.Httpclient, I am trying to do a multipart post in C# and with a wp8.
    This is a snippet of my code:
    varclient =
    newHttpClient();
                    client.DefaultRequestHeaders.TryAddWithoutValidation(
    "Content-Type",
    "application/json");
    MultipartFormDataContent
    content = newMultipartFormDataContent();
    content.Add(
    newStringContent(requestObj,
    Encoding.UTF8,
    "application/json"),
    "request");
    but using Fiddler, I noticed that I am sending this:
    Content-Type: application/json; charset=utf-8
    Content-Dis name=request
    while I need to send this (taken from an android device where the call is working):
    Content-Dis name="request"
    Content-Type: text/plain; charset=UTF-8
     - How to achieve the expected result?

    Your code explicitly sets the incorrect content type.  Why are you setting it to "application/json", when you say it requires "text/plain; charset=UTF-8"?
    Bret Bentzinger (MSFT) @awehellyeah

  • Force file download? Content-Disposition?

    Hello,
    I recently started using an X-Serve with OS X 10.4.8 installed.
    This is my media server, and I'm trying to configure it to force a file download dialog when an mp3 file is pulled.
    I used to do this by using an .htaccess file with the following:
    <FilesMatch "*.mp3">
    ForceType application/octet-stream
    Header set Content-Disposition attachment
    </FilesMatch>
    But it doesn't seem to work now.
    Do I have to add a new Content Handler? If so, what do I put to force a file download?
    Thanks very much

    See Oracle Metalink,
    ..Oracle Portal Technical Forum,
    ....Subject: PORTAL - uploading files (file attachments) with file names.
    This message thread outlines javascript code that automatically captures the filename during an upload.

  • Header variable: Content Disposition for downloading file over HTTP?

    Hi All,
    I have a general content server question...Is there anyway to pass a parameter or set a setting on the content server to send the file with the header variable content-disposition set so that when a user selects a file within a browser, it doesn't open in place but asks the user whether they want to open or save the document?
    Note - I'm actually using this with ArchiveLink and displaying the link in the Portal but this forum seems the closest I can get to asking this question.
    Regards,
    Matt

    Thanks Athol.
    Although there's quite a bit of configuration options there for displaying files, there doesn't appear to be anything that let's you manipulate the HTTP header variables to set content-disposition.
    Any other ideas?
    Cheers,
    Matt
    ps. If you want to artificially see the behaviour I'm after, within IIS, you can predefine this header variable for the contentserver.dll but this makes every HTTP request act like a file that wants to be downloaded, and it calls every file contentserver.<suffix>. From a user perspective, there's nothing worse than a document opening in place in your window (losing the underlying application), or within another IE window, hence why I'd like it to act like a file download.

  • Trying to make oracle-xsql-servlet to work under tomcat

    I am trying setup Setup "oracle-xsql-servlet" to work under tomcat.
    #1. I have installed the xdk from orcale at "C:\xdk_nt_10_1_0_2_0_production"
    #2. I have installed "Apache Tomcat Version 6.0.14"
    #3.
    I have made the following changes to "catalina.bat"
    REM Added for Oracle XSQL Servlet
    REM -----------------------------
    set CLASSPATH=%CLASSPATH%;C:\xdk_nt_10_1_0_2_0_production\lib\xsu12.jar
    set CLASSPATH=%CLASSPATH%;C:\xdk_nt_10_1_0_2_0_production\lib\oraclexsql.jar
    set CLASSPATH=%CLASSPATH%;C:\xdk_nt_10_1_0_2_0_production\lib\xmlparserv2.jar
    set CLASSPATH=%CLASSPATH%;C:\xdk_nt_10_1_0_2_0_production\lib\classes111.zip
    set CLASSPATH=%CLASSPATH%;C:\xdk_nt_10_1_0_2_0_production\xdk\admin
    echo %CLASSPATH%
    #4 created a new folder under "C:\apache-tomcat-6.0.14\apache-tomcat-6.0.14\webapps" xdk
    and created a web.xml in it. Following are the entries is the web.xml:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
         <description>
    XDK Examples.
    </description>
         <display-name>XDK Examples</display-name>
         <servlet>
              <servlet-name>oracle-xsql-servlet</servlet-name>
              <servlet-class>oracle.xml.xsql.XSQLServlet</servlet-class>
              <load-on-startup>1</load-on-startup>
         </servlet>
         <servlet-mapping>
              <servlet-name>oracle-xsql-servlet</servlet-name>
              <url-pattern> *.xsql </url-pattern>
         </servlet-mapping>
    </web-app>
    PROBLEM. When I start up tomcat, I keep getting the following errors.
    SEVERE: Error deploying web application directory xdk
    java.lang.NoClassDefFoundError: javax/servlet/http/HttpServlet
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)     
    OTHER APPLICATIONS such as Examples (provided by apache) work fine.
    Any ideas ?

    XSQL may be used with Tomcat 3.1 and 3.2.
    Refer to section Jakarta Tomcat 3.1 or 3.2
    http://www.oracle.com/technology/tech/xml/xdk/doc/production10g/doc/java/xsql/xsql_userguide.html#ID3386

  • Setting the title for File download dialog when using content-disposition

    I am trying to send a file from server to client (browser). I am setting the content type of the resopnse and using the "content-disposition" header and giving the filename.
    But the issue is, when it is downloading and the dialog box is showing the progress bar, The title of the dialog box is showing something like "40% of localhost:9080.....". It doesn't show the file name in the title bar. Also, if the URL is very long (I am passing some get parameters and the servlet name is also long), I get junk characters like small boxes.
    How to set this title in the servlet?

    Is there a reason why you have to use FileReference.Save versus File.browseForSave?  In Adobe AIR, the File class, which extends the FileReference class,    provides more capabilities and has less security restrictions than the FileReference class.  Using File.browseForSave, it has a title:String parameter which is a string that is diplayed in the title bar of the dialog box.

  • Setting path for "Content-disposition" filename

    I'm trying to figure out how to set the filename in the following:
    String path = "/usr/local/jakarta-tomcat-4.1.29/webapps/myapp/my_images.zip";
    response.setContentType("application/octet-stream");
    response.setHeader("Content-disposition","attachment; filename=" +path);The file that I'd like the user to download is called my_images.zip. It resides here: /usr/local/jakarta-tomcat-4.1.29/webapps/myapp/my_images.zip
    However, when I run the servlet, it pops up a dialog box with this as the filename: usrlocal_jakarta-tomcat-4.1.29_webapps_myapp_my_images.zip
    It's replaced the slashes with underscores. What's going on? The zip file resides in the root folder of my app. The servlet is in a subfolder called "fpauto".

    Ah, ok. Right, so when you set that heading what you are saying to the client is: "The response from this web request is actually a file with the following name..."
    For example you could set it to be README.TXT and then use
    response.getWriter().println("Hello World.");as the only other line of your servlet. That would send a text "file" called README.TXT to the client containing the text "Hello World" only. Setting that response header doesn't tell the servlet to do anything other than inform the client what filename to use.
    It would be nice if there was a method called "transmit file" or somesuch, but there isn't. The simplest reason why is that if you just want to send a file you can usually provide it directly from the web (or app) server by putting it into the content. For example create a file my_files.zip in the root of your war and it will typically be made available as a file anyway.
    The assumption is that servlets are for generating content not just sending content that already exists.
    However, if you have a good reason for wanting to do this, you can create a loop that reads in the file and sends its contents to the response's output stream. I usually use the commons-io IOUtil [copy |http://commons.apache.org/io/api-1.4/org/apache/commons/io/IOUtils.html#copy(java.io.InputStream,%20java.io.OutputStream)] functions to do this.
    So why do you want to use a servlet to send "static" content?

  • Setting up the XSQL Servlet engine

    I am trying to set up the XSQL servlet component of 9iAS. From what I read all of the necessary components are included in 9iAS, there is no need to download the XSQL servlet from technet. Is this true? I try to run the demo's (e.g. hello world) but am always getting a connection refused error. I edited the XSQLConfig.xml file to include the host, port and sid but still no luck.
    I am at a loss. I have 8.1.7 SE database installed with JDBC drivers, 9iAS 1.0.2. Is this all I need or do I have to download something else.

    Steven,
    Thanks for responding. I am a DBA so I'm only 50% incompetent. The 9iAS version is 1.0.2.1.0 Solaris and the DB is 8i SE, right now on the same Solaris box. The Jserv and JSP demos on the initial install home page work fine and I was able to get Oracle Portal running etc. so I think the Server is working. When I check the installed products for the DB I see several JDBC drivers appear to be installed.
    segmet from XSQLConfig.xml:
    <connection name="demo">
    <username>scott</username>
    <password>tiger</password>
    <dburl>jdbc:oracle:thin:@192.100.146.22:1521:NPGSDEV</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    </connection>
    I can connect scott/tiger@npgsdev in sqlplus as well as tnsping npgsdev and the port is 1521 so the tnslistener is up and running.
    I can call up the demo page at: http://192.100.146.22:7777/xsql/java/xsql/index.html
    but any attempt to run them gives:
    Oracle XSQL Servlet Page Processor 1.0.0.0 (Production)
    Oracle XSQL Servlet Page Processor 1.0.0.0 (Production)
    XSQL-007: Cannot acquire a database connection to process page.
    Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    Any help would be greatly appreciated. -quinn

  • Content-Disposition - Dynamically set in Mail Adapter

    Hi All,
    I need to dynamically set the Content-Disposition in the receiver mail adapter so as to facilitate dynamic names for my attachment in the mail.
    In case i use messagetransform bean, I will have to hard code the name as part of the parameter value in the adapter.
    Is there any way i can utilize the ASMA and dynamic configuration here?
    The specified item was not found. - i referred the blog but instead of setting the
    attachmentXML.setName(mailFileName);
    attachmentXML.setContentType("text/xml");
    attachmentXML.setContent(by);
    I need to set the content disposition. Is there any way?
    Appreciate all help on this issue.
    Regards,
    Shabz

    Hi Vijay,
    Do have the solution for this? I also have the same requirement.
    Please forward me the solution.
    Thanks,
    Nat

  • Error #2190: The attempted load of failed as it had a Content-Disposition of attachment set.

    I'm getting this error when I set the URL.
    Error #2190: The attempted load of  http://site.com/get_file_content.php?id=1000 failed as it had a Content-Disposition of attachment set.
    Is there a way to force the content type on the client?
    Here is the code I'm using:
                var resource:URLResource = new URLResource(path);;
                var element:SWFElement = new SWFElement(resource);
                mediaPlayer = new MediaPlayer();
                element.resource.mediaType = MediaType.SWF;
                mediaPlayer.media = element;
                mediaPlayer.addEventListener(MediaErrorEvent.MEDIA_ERROR, mediaErrorHandler);
                mediaPlayer.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, mediaPlayerStateChangeHandler);
                mediaPlayer.addEventListener(DisplayObjectEvent.DISPLAY_OBJECT_CHANGE, mediaPlayerDisplayObjectHandler, false, 0, true);
                protected function mediaPlayerDisplayObjectHandler(event:DisplayObjectEvent):void {
                    var displayObject:DisplayObject = event.newDisplayObject;
                    displayObject.width = 400;
                    displayObject.height = 250;
                    uicomponent.addChild(displayObject);
                protected function mediaErrorHandler(event:MediaErrorEvent):void {
                    trace(event.error.detail);
                    // Error #2190: The attempted load of  http://site.com/get_file_content.php?id=1000 failed as it had a Content-Disposition of attachment set.
    Message was edited by: thx1138

    The problem is that the server script is treating the request as a request for a file to download, rather than as a typical HTTP request/response.  You need to modify the server script so that it doesn't include the Content-Disposition header, there's not much you can do on the client side.

  • Cannot set text field contents

    here is my code so far.
    global theWatchedFolder
    on clicked theObject
    set theWatchedFolder to choose folder
    set contents of text field "hfDirectory" to theWatchedFolder
    end clicked
    when i click on the button theObject it brings up the prompt to choose a folder.
    but it kicks out with the error
    Can't set <<class texF>> "hfDirectory" to alias "path to my selected folder"
    All i want is the path to the folder i selected to show up in the text field.
    what am i doing wrong
    thanks in advance,
    Pendal

    Two thoughts.
    theWatchedFolder is an alias, so you might need to coerce it to text.
    Secondly, you are ambiguous about which field to set - where is the field?
    Therefore, try:
    set contents of text field "hfDirectory" of window "windowName" to (theWatchedFolder as text)

  • Can not make XSQL servlet running under Jrun 3.1! need help

    Hi,
    I tried to run Oracle XSQL servlet under JRun 3.1,I did servlet mapping, such as
    <servlet-name>oracle-xsql-servlet</servlet-name>
    <servlet-class>oracle.xml.xsql.XSQLServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>oracle-xsql-servlet</servlet-name>
    <url-pattern>*.xsql</url-pattern>
    </servlet-mapping>
    I set classpath for XSQL related library such as oraclexsql.jar, xmlparserv2.jar,etc, I believe everything is setup correctly, however when I invoke .xsql page, I did not get data instead of getting sql text!, here is my xsql file content:
    <?xml version="1.0"?>
    <!-- reports.xsql: List of reports by user id -->
    <?xml-stylesheet type="text/xsl" href="Filter.xsl"?>
    <page connection="reports_8i" xmlns:xsql="urn:oracle-xsql">
         <dataform target="reportFilter.jsp" submit="Go">
    <xsql:set-session-param name="userid" value="{@userid}" ignore-empty-value="no"/>
         <xsql:include-param name="userid"/>
         <xsql:set-session-param name="bu_id" value="{@bu_id}" ignore-empty-value="no"/>
         <xsql:include-param name="bu_id"/>
         <xsql:set-session-param name="client_id" value="{@client_id}" ignore-empty-value="no"/>
         <xsql:include-param name="client_id"/>
         <item type="list" name="targetPage" label="Available Reports">
         <xsql:ref-cursor-function bind-params="userid">
                   reports_generation.getReportList(?)
              </xsql:ref-cursor-function>
              </item>
         </dataform>
    </page>
    What I got when I invoked this page is reports_generation.getReportList(?)!!
    It seems that JRun 3.1 did not understand xsql syntax, it means it can not find XSQL servlet related libraries, come on, I did set classpath.
    Does anyone has this experience to help me out? Highly appreicate you in advance.
    Thanks.

    i think i solved this problem by specifying the full path to javac...
    what must i do to avoid this?

  • Inline type of Content-Disposition problem in IE

    Hi,
    In a project, we need post some information from applet to servlet. The servlet will send some files back. We like the files shown on browsers. So we set the header in servlet as
    response.setHeader("Content-Disposition",
    "inline;filename=\"" + fileName + "\"");
    We use JSobject in applet to call form from a html file to post the information to servlet, target of the form is set as "_blank", which suppose will open a new browser and show the file. For example if the file is a word file, the IE will show the file inside browser.
    However, if two files need to be shown, only the first file is shown, the other browser is blank, and when you kill the blank window, the other will turn to blank window too. We test other types of file, xls files have similar problem, the PDF files work OK. Two things can fix the problem, one is set the form method to ��get��, the other is changing the header from ��inline�� to ��attachment��. But we can't use any of them under the project requirement. Has anyone experienced such wield behavior and know the reason? Is this the bug of IE?
    Thanks in advance!

    Here are a little more about the file types.
    The files we test have problems are msword or excel files, I think all MS office type files have the problem. Same problem even you mix them, for example one word file and one excel give you the same problem as two word files.
    However there is no problem if I view several PDF files. If we mix the word file with pdf file. If the first file to view is PDF, then it works OK. Otherwise same problem.
    The browser we are testing IE 6.0 with SP1.

  • Content-Disposition not working!

    Hi!, I've a servlet which its purpose is to read a file and write it later using a ServletOutputStream. This file must not be wrote as text, but instead the idea is to write it and then browser open it with a specific application. The extension of this file is already asssociated with the program that I want to use to open it. In fact, if I use a url link to the file, the browser requests the application and all goes fine, but I want that this application runs inside the browser, so I'm using content-disposition: inline; in order to do this, but I can't make it! The browser always try to download the file. My code is this:
    import java.util.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class imflpruebas extends HttpServlet{
         private ResultSet rs, rs2;
         private Connection connection;
         private Statement statement;
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              doPost(request,response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
              response.setHeader("Content-Disposition","inline");
              response.setContentType("application");
              String sFileName = "F:\\jakarta-tomcat-4.1.24\\webapps\\ImaxFileWeb\\temp\\reno_PRUEBA_0_0_0.IMX";
              File file = new File(sFileName);      
              byte[] byteContents = new byte[(int)file.length()];                
              FileInputStream in = new FileInputStream(sFileName);                
              int retcd = in.read(byteContents);                
              in.close();
              ServletOutputStream out = response.getOutputStream();
              out.write(byteContents);
              out.flush();
              out.close();
    }          I've tried to put the content type before the set header and the result is the same.
    Any ideas?
    Best whishes
    Raul          

    Hello Raul,
    There are a few things to consider. First of all, how do you want the browser to tell which application to use. Your content-type is very non-specific so the browser would never be able to tell by itself. Using a mime-type which has been mapped to an application might do a lot.
    Second, if you are using IE mime-types have little influence. IE tries to recognize the data by looking at the raw bytes and see if it recognizes the format. If not, IE will look at the URL and determine what to do with the data based on the URl extension. So if you have a link http://..../xxx.xls IE will try to show the data using Excel (if installed obviously). Adding such an extension (that can be ignored by the servlet) can do the trick with IE.
    If using IE check the Windows Explorer file settings (based on extensions). There is an "advanced" property called "confirm open before download" which should be cleared to allow an automatic open. Clearing the check "always ask before downloading" on the browser popup has no effect at all.
    Hope this helps.
    Regards,
    Silvio Bierman

Maybe you are looking for