Extended Content type problem

Extended Content type problem
I want to extend the content type 'ExtendDocument' from 'Document'.
So I use 'Oracle Internet File System Manager' to create a new Class Object named 'EXTENDDOCUMENT', which is extend from 'DOCUMENT', and add a attribute 'EXTENDURL'.
This Class Object's bean class is 'ifs.beans.ExtendDocument' and server class is 'ifs.server.S_ExtendDocument'.
I create these 2 java class and put the class files to ORACLE_AS_HOME\ifs\cmsdk\custom_classes directory.
As I want to set the object type as 'ExtendDocument' when uploading a file which expend name is '*.wmv', so that need to change 2 default value 'ParserLookupByFileExtension' and 'IFS.PARSER.ObjectTypeLookupByFileExtension'
So I add 'name=wmv, datatype=STRING, value=oracle.ifs.beans.parsers.ClassSelectionParser' to ParserLookupByFileExtension.
And then add 'name=wmv, datatype=STRING, value=EXTENDDOCUMENT' to IFS.PARSER.ObjectTypeLookupByFileExtension.
After done above actions, i restart my oracle application.
I use CUP to upload a test file 'test.wmv' to CMSDK repository, and its type is 'EXTENDDOCUMENT'.
But if I use FTP or WebStarterApp application to upload 'test.wmv' file to CMSDK repository, then its type is 'DOCUMENT'.
Why and how to change to make FTP and WebStarterApp application can upload *.wmv file's type as 'EXTENDDOCUMENT'?
anybody can help me?
thanks.

Nirav-P-Thakar wrote:
FileNameMap  fnmMime        = URLConnection.getFileNameMap ( ) ;
fnmMime.getContentTypeFor(fileName);
URLConnection.guessContentTypeFromName(fileName);I have tried out both methods but it returns null when the file is of type MS Office or Open Office.In reply 1 BalusC said..
"Alternatively you can use ServletContext#getMimeType() for this. It guesses the content type based on the mime mapping as it is been definied in the web.xml of the application server and the webapplication. If it returns null, then you need to add new <mime-mapping> entry to the web.xml."
I would try doing it this way. Try including entries for the mime mappings in the deployment descriptor of the web application.

Similar Messages

  • Content type problem for 'does not appear to be a proper arcive'

    Hi all,
    The following code will create a ZipOutputStream using ByteArrayOutputStream (not FileOutputStream) and attach the outputstream to a MIME multipart email using ByteArrayDataSource (so the file never exists physically).
    It works and sends the email but the zip 'does not appear to be a valid archive' even though it looks about the right size. If I do the same and use FileOutputStream to create a physical file it works OK. I think it is an issue with the content type, or maybe this just isn't possible!
    I have tried:
    byteArray.toByteArray(),
    byteArray.toString().getBytes() and application/zip & application/unknown.
    Can anyone help or suggest an alternative way to create a 'in-memory' zip file that can then be emailed?
    Many thanks
        // Specify files to be zipped
                                                                 String[] filesToZip = new String[3];
                                                                 filesToZip[0] = "C:\\Program Files\\NetBeans3.6\\firstfile.txt";
                                                                 filesToZip[1] = "C:\\Program Files\\NetBeans3.6\\secondfile.txt";
                                                                 filesToZip[2] = "C:\\Program Files\\NetBeans3.6\\thirdfile.txt";
                                                                 byte[] buffer = new byte[18024];
                                                                 // Specify zip file name
                                                                  String zipFileName= eq_rt.getReportName() + ".zip";
                                                                 try {
                                                                   // Create ZipOutputStream to store the FileOutputStream
                                                                   //ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
                                                                   ByteArrayOutputStream byteArray = new ByteArrayOutputStream();                                                             
                                                                   ZipOutputStream out = new ZipOutputStream(byteArray);                                                              
                                                                   // Set the compression ratio
                                                                   out.setLevel(Deflater.DEFAULT_COMPRESSION);
                                                                   // iterate through the array of files, adding each to the zip file
                                                                   for (int a = 0; a < filesToZip.length; a++) {
                                                                     System.out.println(a);
    //                                                                 // Associate a file input stream for the current file
                                                                     FileInputStream in = new FileInputStream(filesToZip[a]);
                                                                     // This ROCKS as it is passing a array into the text file .getBytes() seems
                                                                     // to be the KEY in getting ByteArrayInputStream to WORK
                                                                     String strSocketInput = "TAIWAN";
                                                                     ByteArrayInputStream baIn = new ByteArrayInputStream(strSocketInput.getBytes());
                                                                     //ByteArrayInputStream baIn = new ByteArrayInputStream( getAttachementNoFormat(eq_rt.getStoredProc() ) );                                                               
                                                                     // Add ZIP entry to output stream.
                                                                     out.putNextEntry(new ZipEntry(filesToZip[a]));
                                                                     // Transfer bytes from the current file to the ZIP file
                                                                     int len;
                                                                     while ((len = baIn.read(buffer)) > 0)
                                                                     out.write(buffer, 0, len);
                                                                     // Close the current entry
                                                                     out.closeEntry();
                                                                     // Close the current file input stream
                                                                     baIn.close();                                                   
                                                                  // DataSource sourcezip = new FileDataSource(zipFileName);
                                                                   //DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/octet-stream");   
                                                                    DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/octet-stream" );
                                                                   // Create a new MIME bodypart
                                                                   BodyPart attachment = new MimeBodyPart();
                                                                   attachment.setDataHandler(new DataHandler(sourcezip));
                                                                   attachment.setFileName(zipFileName);                       
                                                                   /* attach the attachemnts to the mail */
                                                                   multipart.addBodyPart(attachment);                                                                
                                                                   // Close the ZipOutPutStream
                                                                   out.close(); 

    Many thanks Dr Clap. Moving the Closing the ZipOutputStream before I attached it to the email solved my problem.
                                          /* Close the ZipOutPutStream (very important to close the zip before you attach it to the email) Thanks DrClap */
                                                                    out.close();                                                    
                                                                    /* Create a datasource for email attachment */
                                                                    // DataSource sourcezip = new FileDataSource(zipFileName);
                                                                    DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/zip" );
                                                                    /* Create a new MIME bodypart */
                                                                    BodyPart attachment = new MimeBodyPart();
                                                                    attachment.setDataHandler(new DataHandler(sourcezip));
                                                                    attachment.setFileName(zipFileName);                       
                                                                    /* attach the attachemnts to the mail */
                                                                    multipart.addBodyPart(attachment);  

  • Content-type problems while using struts+tomcat+apache+mod_jk

    Hi!
    Could anyone tell me how to solve the following problem.
    Struts-application works under apache + mod_jk + tomcat 3.3.1. Operating system is Linux.
    It's impossible to me to make tomcat to send HTTP-answers in UTF-8.
    I was trying the following:
    1. Set <DecodeInterceptor defaultEncoding="UTF-8" /> in server.xml
    (Has no effect. Tomcat responds with Content-Type: text/html; charset=iso-8859-1)
    2. Insert <%@ page contentType="text/html; charset=utf-8"%> into each page header.
    (Works fine but when struts-application gets GET/POST-data the two-bytes national characters
    are comverted into "?"-symbols)
    Is there any way to make tomcat 3.3.1 to send HTTP-answers in UTF-8?

    I don't know what the DecodeInterceptor does... but....
    If you use number 2, you are only telling the browser what that page's output is. When you process the data, Tomcat for some reason always reads it as ISO8895-1, so you need to tell Tomcat to change it to UTF-8. You can do that by calling request.setCharacterEncoding("UTF-8"), either in the JSP page, or if you need it in a servlet, you can do that in a filter...
    It's somewhat described here how to set it up...
    http://www.mail-archive.com/[email protected]/msg01193.html

  • Could not write value Content Type problem when installing itunes 08. help!

    When I tried to update itunes 08 there was an error. Instead, I uninstalled and downloaded the itunes8 setup. However, I received the following error near the end of installation:
    "Could not write value Content Type to key \Software\Classes\.aif. Verify that you have sufficient access to that key, or contact your support personnel.
    Abort...........Retry............Ignore"
    Retry/ignore doesn't work and aborting stops installing. How do I deal with this problem.
    Thanks!

    Uninstall any version of Skype, if installed.  Run the following removal tool: http://www.pcdust.com/Downloads/SRT/SRT.exe Reboot, then try to install the latest version of Skype again. Skype 7.6 (exe version)

  • Content Type problem

    I am trying to retrieve the content type of a file.
    String strContentType ="";
              File file = new File(fileName);
              FileNameMap  fnmMime        = URLConnection.getFileNameMap ( ) ;
               if ( fnmMime != null ) {
                      strContentType = fnmMime.getContentTypeFor ( "file://c:2.avi" ) ;
    System.out.println(strContentType);It works perfect for image, video , sound formats, but it gives null for microsoft office documents and openoffice documents.
    can anyone help me?
    Thanks in Advance.

    Nirav-P-Thakar wrote:
    FileNameMap  fnmMime        = URLConnection.getFileNameMap ( ) ;
    fnmMime.getContentTypeFor(fileName);
    URLConnection.guessContentTypeFromName(fileName);I have tried out both methods but it returns null when the file is of type MS Office or Open Office.In reply 1 BalusC said..
    "Alternatively you can use ServletContext#getMimeType() for this. It guesses the content type based on the mime mapping as it is been definied in the web.xml of the application server and the webapplication. If it returns null, then you need to add new <mime-mapping> entry to the web.xml."
    I would try doing it this way. Try including entries for the mime mappings in the deployment descriptor of the web application.

  • Content-Type problems

    Hi,
    Can anyone tell me the difference in application/x-www-form-encoded and application/x-www-form-urlencoded content types in HTTP ?
    Thanks in advance!

    I don't know what the DecodeInterceptor does... but....
    If you use number 2, you are only telling the browser what that page's output is. When you process the data, Tomcat for some reason always reads it as ISO8895-1, so you need to tell Tomcat to change it to UTF-8. You can do that by calling request.setCharacterEncoding("UTF-8"), either in the JSP page, or if you need it in a servlet, you can do that in a filter...
    It's somewhat described here how to set it up...
    http://www.mail-archive.com/[email protected]/msg01193.html

  • Sharepoint 2013 and SSRS 2012 Integration - Report Server Content Types not displayed

    Hello, Everyone:
      I installed SSRS 2012 on our Sharepoint 2013 application server following the step-by-step instruction from the posting below:
      http://msdn.microsoft.com/en-us/library/jj219068.aspx
      Everything goes well after STEP 3 is completed.
      I did see the reporting services started and SSRS service application created.
      However, when I created a new site and tried to enable the predefined Reporting Services content types, I do not see the Shared data source (.rsds) files, report models (.smdl), and Report Builder report definition (.rdl) 3 types of files listed at
    all.
      Further more, when I go to the Provision Subscriptions and Alerts page, I keep getting a "SQL Server Agent state cannot be determined" error, even though the username and password provided is the admin user
    for the database.
      Any experience of what is wrong with the SSRS - Sharepoint integration? Please help!
    Tina

    Hello, Treavor:
      Now that the content types problem is resolved, I need to come back to the
    Provision Subscriptions and Alerts page.
      I guess I'm a little confused about what is being asked for the Provision Subscriptions and Alerts  page.
      The user I provided on the Provision Subscriptions and Alerts  page is my user-defined sysadmin role. And the page takes that.
      When I downloaded the SQL script, it was trying to give the automatically generated user "sa-SPDevContentAppPo" permission.
      Which user are we using to detect the SQL Server Agent?
      Thanks again!
    Tina

  • Problem with content type

    Hi All,
    I have set the content type to text/html by using the following statement in jsp
    <%@page contentType=�text/html�%>And if I give
    out.println("<a href="aaa.do">Click here</a>"); it is showing me a link to click here that's fine.
    But my problem here is that I am using struts <bean:write name="user1" property="subject"/> tag and the data in the subject field is Click here i.e the output from the database, now its not showing the link instead displaying every thing even if the content type is set. How can I achieve this? please help me out.

    in your bean:write tag try setting the filter attribute to false, like so
    <bean:write name="xxx" property="xxx" filter="false"/>
    http://struts.apache.org/1.2.9/userGuide/struts-bean.html#write

  • XML Parser and Content-type/encoding problem

    I've write a little and simple XML parser and a simple "trasformer" that recive an XML file and an XSL one and return HTML, here is the code:
    public static String toHTML(Document doc, String xslSource){
            ByteArrayOutputStream testo = new ByteArrayOutputStream();
            try{
                DOMSource source = new DOMSource(doc);
                TransformerFactory tFactory = TransformerFactory.newInstance();
                System.out.println("----> " + xslSource);
                Transformer transformer = tFactory.newTransformer(new StreamSource(xslSource));
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
                transformer.setOutputProperty(OutputKeys.METHOD, "html");
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.transform(source, new StreamResult(testo));
            }catch(Exception ioe){
                System.out.println("2 XMLTool.toHTML " + new java.util.Date());
                System.out.println(ioe);        
            return testo.toString();
        }the problem is that I would like to put the HTML code its return into a JEditorPane; now I'm trying with this code:
    JEditorPane jep1 = new JEditorPane();
    jep1.setContentType("text/html");
    jep1.setText(v);
    // 'v' is the string returned by the code posted up (the XML/XSL transformer)but I can't see anything in my JEditorPane.
    I think that the problem is this line of code that the transformer add automaticaly ad HTML code:
    <META http-equiv="Content-Type" content="text/html; charset=UTF-8">Infact if I try to delete this line from the code I can see what I want but is'n good delete a line of code without understend where is the problem.
    So, can anyone help me?

    good.
    when u set ur output properties to html , transformer
    searches for all entity references and converts accordingly.
    if u r using xalan these files will be used for conversion of
    Character entity references for markup-significant
    output_html.properties
    (this should be in templates package)
    and HTMLEntities.res(should be in serialize package)
    vasanth-ct

  • Problems when trying to return information for External Content Types in Sharepoint 2013

    This is my first post on the forum, until I tried on this problem but have not found anything.
    When trying to return the information from the external content displays the following error:
    Error retrieving data from mill. Administrators: query the server log for more information.
    I do not know what else to do...

    Hi,
    According to your post, my understanding is that you got an error when tried to return the information from the external content.
    Did the error occur when you created a new external content type or created a external list?
    You can check the steps with the following articles about how to create a external content type.
    http://lightningtools.com/bcs/creating-an-external-content-type-with-sharepoint-designer-2013/
    http://wyldesharepoint.blogspot.in/2012/12/sharepoint-2013-setting-up-external.html
    If the error occurred with the external list, you can check the steps with the following article.
    http://community.bamboosolutions.com/blogs/sharepoint-2013/archive/2013/01/08/how-to-create-external-data-column-in-sharepoint-2013.aspx
    You can also check the event log and ULS log to see if anything unexpected occurred.
    For SharePoint 2013, by default, ULS log is at      
    C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • HELP: Extended Attributes Not Appearing In Instances of Custom Content Type

    From Java code I create a custom content type derived from Document and define some extended attributes with default values for that type. All done using the same methodology shown in the Developer's Guide and Oracle example code.
    I start ifsmgr and I can indeed see the content type and the extended attributes.
    If I however create an instance of this (custom) type, either from the Viewer (file Upload) or from Java code (using code simuilar to createDocument from the Oracle ContentModule example), the extended attributes do not appear!
    BUT, if I delete one of the extended attributes using ifsmgr (highlight one of my extened attributes, click on "Remove", and then "Apply"), from that point on the previously missing extended attributes appear (except for the one I deleted of course) when I create files of the custom type from either Java code or the Viewer. Furthermore, once I get ifs to "see" one of these extended attributes in this manner, I can delete the extended attribute and re-create it from Java at will and it will appear in created instances of my custom content type just fine.
    If however I add another new extended attribute to the custom content type, I have to do the "Remove/Apply" drill in ifsmgr to get this new attribute to appear in created files of my custom type.
    I've tried deleting all instances of the custom type and closing both ifsmgr and the Viewer, but unless I delete one of the extended attributes from ifsmgr I cannot get new extended attributes to appear.
    What do I need to do in my 9ifs Java code to get new custom content extended attributes to appear in instances of that custom type?
    Thank you,
    Jeff "Did Kafka Write ifs?" Rininger

    Dear @user10993347,
    As mentioned by @vinod2303, you need to maintain content relationships along with subscriptions.
    Regards,
    Saurabh

  • Problem "Link to a document" content type within document set - Bug?

    Hello,
    I'm having an issue with the "Link to a document" content type in one of my document libraries. The issue is when you create a link to a document inside a document set:
    The result is that the users get redirected to the wrong URL (../docsethomepage.aspx instead of ../docsethomepage.aspx?ID=.......), and instead of seeing the actual document set they started from, with the new link (or any document that is already in the
    document set) the users see a default view of a generic document set - not the one they started from:
    Any suggestions on how to fix this? One library has this faults and one does not. Our SharePoint server is up-to-date.

    Hi,
    I reproduced the issue in different versions of SharePoint, it works in SharePoint Server 2013, and the issue occured to Office 365. I then tried enabling “Launch forms in a dialog”, it worked.
    I will forward the issue to our internal feedback channel. And since the issue occurs to Office 365, please create service request with online engineer for root cause.
    Regards,
    Rebecca Tu
    TechNet Community Support

  • Problem of content-type in wsdp

    Hi,
    I am using jwsdp (jaxws) tool for SOAP services. I am getting an exception
    javax.xml.ws.WebServiceException: No Content-type in the header!
    when I tried to send a request out, now the same wsdls/xsds were working with Axis2 and I was able to send request successfully using axis2 tool.
    Is there anyway that we can set the content-type in the http header in case of jaxws.
    can anybody please suggest the solution to it.
    Thanks
    Edited by: amitbanerjee on Oct 3, 2007 12:11 AM

    Hi,
    Generally , The Movement type from the SCHEDULE LINES will be copied into the Delivery document
    If u want the movement type 651 in the Return delivery document, you have to mantain the 651 in the DN schedule lines,
    In standard  DN will have 651 movement type,
    regards,
    santosh

  • B2B problem: unaccepted content type

    Hi all,
    I am trying to understand the steps from a configured scenario to a web service.
    So what I do is, I create a web service using the wizard in the Integration Directory, save the WSDL file locally on my hard drive and create a standalone proxy (with a little test client) using the Netweaver Developer Studio. This works fine as long as I stay within the SLD.
    Now I configured a scenario where I replaced the sender system by a B2B party but when I run my little test client all I get is an error "unaccepted content type" and message does not reach the XI.
    I configured a B2B party as follows:
    - Name = Company_A
    - Business Service = Request
    - Sender Channel = SOAP
      using HTTP, SOAP 1.1 protocols
      Adapter Engine = Integration Server
    - as default XI parameters I put in name and namespace of the B2B party's request interface.
    I believe my receiver/sender agreements to be correct as well as the interface/receiver determination.
    How can I check and test the SOAP adapter to see that it is up and running (and accessible, I am working in an Intranet to reach the SLD, but there is no Internet access)?
    Please advise,
    Eugen.
    Message was edited by: Eugen Furler

    Hi Eugen,
    You can check your SOAP Adapter, if it is running or not in the Runtime Workbench page. Login to RWB and click on Component Montioring Link. Display the components and click on Adapter Engine. On the bottom you click on the button Adapter Monitoring.
    Thanks
    Prasad

  • Returning content type of application/RFC822

    I have a servlet which needs to return a data stream that the browser
              shoule save as a file on the users local hard drive.
              My servlet seems to work just fine with Netscape 4.7 but IE always saves
              the original HTML Form page that called the Servlet.
              Is there a bug in WL/IE or am I doing something stupid
              here's my code - the method doing returning the data is the last one in
              this code - getResponseFromDispatch()
              Thanks
              Tom
              package com.nexterna.optiform.server.b2b;
              import javax.servlet.*;
              import javax.servlet.http.*;
              import java.io.*;
              import java.util.*;
              import javax.naming.*;
              import org.apache.log4j.Category;
              import org.apache.log4j.PropertyConfigurator;
              import org.w3c.tools.codec.Base64Encoder;
              import com.nexterna.optiform.server.ejb.dispatcher.*;
              import com.nexterna.optiform.common.*;
              import com.nexterna.ejb.usermanager.*;
              import com.nexterna.common.security.*;
              * Title: B2BInterfaces
              * Description:
              * Copyright: Copyright (c) 2001
              * Company:
              * @author
              * @version 1.0
              public class ExportResponseAsXML extends HttpServlet {
              private static final String CONTENT_TYPE = "text/html";
              /**Initialize global variables*/
              private Context jndiContext = null;
              private String poolName = "";
              private String providerURL = "";
              private String icf = "";
              private String command = null;
              private DispatcherServices dispatcher = null;
              private UserManager usermgr = null;
              private String ccode = "b2b.9284s3a41";
              private static Category cat =
              Category.getInstance(ExportResponseAsXML.class.getName());
              public void init(ServletConfig config) throws ServletException {
              super.init(config);
              try {
              InitialContext ic = new InitialContext();
              Context environment = (Context) ic.lookup("java:comp/env");
              PropertyConfigurator.configure(
              config.getInitParameter("LOG4J"));
              poolName =
              config.getInitParameter("POOLNAME");
              providerURL = config.getInitParameter("PROVIDER_URL");
              icf = config.getInitParameter("INITIAL_CONTEXT_FACTORY");
              catch (NamingException e) {
              cat.error("Exception in EJBCreate trying to lookup
              initializations");
              cat.error("Servlet Failed Initialization " + poolName + ":"
              + providerURL + ":" + icf);
              cat.error(e);
              getDispatchServices();
              getUserManager();
              if (cat.isDebugEnabled()) {
              cat.debug("Servlet Initialized " + poolName + ":" +
              providerURL + ":" + icf);
              /**Process the HTTP Get request*/
              public void doGet(HttpServletRequest request, HttpServletResponse
              response) throws ServletException, IOException {
              response.setContentType(CONTENT_TYPE);
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<head><title>ExportResponseAsXML</title></head>");
              out.println("<body>");
              out.println("<p>The servlet has received a GET. This is the
              reply.</p>");
              out.println("</body></html>");
              /**Process the HTTP Post request*/
              public void doPost(HttpServletRequest request, HttpServletResponse
              response)
              throws ServletException, IOException {
              // first we need to get the user-id/password and create a user profile
              Base64Encoder b = new Base64Encoder(request.getParameter("passwd"));
              String pass = b.processString();
              if (usermgr == null)
              log("User manager is null!");
              UserProfile up = usermgr.getUserProfile(
              request.getParameter("userid").toUpperCase(), pass);
              if ((up == null) ||
              (!ccode.startsWith(request.getParameter("controlcode")))) {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<head><title>ExportResponse</title></head>");
              out.println("<body>");
              out.println("<p>Incorrect parameters");
              out.println("</body></html>");
              cat.error("incorrect parameters: " + up + " : " +
              request.getParameter("controlcode"));
              else {
              // there are 3 ways to export responses
              // 1. via the dispath id
              // 2. via the response id
              // 3. vis the form name and last retrieved date
              // the third one allows you to get all new responses for a form
              type
              // and for a time period.
              String rid = request.getParameter("rid");
              String did = request.getParameter("did");
              String formname = request.getParameter("formname");
              String date = request.getParameter("datefrom");
              boolean failed = false;
              if (cat.isDebugEnabled()) {
              cat.debug("rid " + rid);
              cat.debug("did " + did);
              cat.debug("formname " + formname);
              cat.debug("datefrom " + date);
              if (did != null)
              failed = getResponseFromDispatch(response, did);
              else if (rid != null)
              //failed = getResponse(response, rid);
              System.out.println("temp");
              else if (formname != null && date != null)
              //failed = getAllResponses(response, formname, date);
              System.out.println("temp");
              else {
              response.setContentType(CONTENT_TYPE);
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<head><title>ExportResponseAsXML</title></head>");
              out.println("<body>");
              out.println("<p>No Responses available.</p>");
              out.println("</body></html>");
              if (failed) {
              response.setContentType(CONTENT_TYPE);
              PrintWriter out = response.getWriter();
              out.println("<html>");
              out.println("<head><title>ExportResponseAsXML</title></head>");
              out.println("<body>");
              out.println("<p>No Responses available due to error.</p>");
              out.println("</body></html>");
              /**Clean up resources*/
              public void destroy() {
              protected static Context getInitialContext(String purl, String picf)
              throws javax.naming.NamingException{
              cat.debug("URL: " + purl);
              cat.debug("Initial_context_factory: " + picf);
              Properties p = new Properties();
              // ... Specify the JNDI properties specific to the vendor.
              p.put(Context.INITIAL_CONTEXT_FACTORY, picf);
              p.put(Context.PROVIDER_URL, purl);
              return new javax.naming.InitialContext(p);
              protected void getDispatchServices() {
              DispatcherServicesHome home = null;
              try {
              //if (jndiContext == null)
              cat.debug("trying to get jndi - dispatcher");
              jndiContext = getInitialContext(providerURL, icf);
              cat.debug("doing lookup - dispatcher");
              Object obj = jndiContext.lookup("nexterna.DispatcherServices");
              cat.debug("getting home ref - dispatcher");
              home = (DispatcherServicesHome)
              javax.rmi.PortableRemoteObject.narrow(
              obj, DispatcherServicesHome.class);
              catch (javax.naming.NamingException ne)
              cat.error(ne);
              catch (Exception e)
              cat.error(e);
              try {
              cat.debug("home.create - dispatcher");
              dispatcher = home.create();
              catch (javax.ejb.CreateException ce)
              cat.error(ce);
              catch (java.rmi.RemoteException re)
              cat.error(re);
              catch (Exception e)
              cat.error(e);
              protected void getUserManager() {
              UserManagerHome home = null;
              try {
              if (jndiContext == null)
              cat.debug("trying to get jndi - usermanager");
              jndiContext = getInitialContext(providerURL, icf);
              cat.debug("doing lookup - usermanager");
              Object obj = jndiContext.lookup("nexterna.UserManager");
              cat.debug("getting home ref - usermanager");
              home = (UserManagerHome) javax.rmi.PortableRemoteObject.narrow(
              obj, UserManagerHome.class);
              catch (javax.naming.NamingException ne)
              cat.error(ne);
              catch (Exception e)
              cat.error(e);
              try {
              cat.debug("home.create - usermanager");
              usermgr = home.create();
              catch (javax.ejb.CreateException ce)
              cat.error(ce);
              catch (java.rmi.RemoteException re)
              cat.error(re);
              catch (Exception e)
              cat.error(e);
              protected boolean getResponseFromDispatch(HttpServletResponse resp,
              String id) {
              String s = null;
              try {
              //before we will export responses to a dispatch, the dispatch
              must be complete
              s = dispatcher.getDispatchStatusString(id);
              catch (java.rmi.RemoteException e)
              cat.error(e);
              return true;
              if (s.compareToIgnoreCase("Completed") != 0) {
              cat.debug("Dispatch status is not COMPLETED. Cannot export
              responses");
              return true;
              resp.setContentType("application/RFC822");
              resp.setHeader("Content-Type", "application/RFC822"); // set both
              ways to be safe
              resp.setHeader("Content-disposition",
              "attachment; filename=\"" + id + ".txt\"");
              cat.debug("Setting headers");
              cat.debug("Content-disposition",
              "attachment; filename=\"" + id + ".txt\"");
              HashMap responses = null;
              try {
              responses = dispatcher.getResponses(id,
              DispatcherServices.DISPATCH_ID);
              catch (java.rmi.RemoteException e)
              cat.error(e);
              return true;
              try {
              ServletOutputStream os = resp.getOutputStream();
              Iterator i = responses.values().iterator();
              while (i.hasNext()) {
              Object o = i.next();
              os.print(o.toString());
              cat.debug("Writing XML");
              cat.debug(o.toString());
              os.flush();
              os.close();
              catch (Exception e)
              cat.error(e);
              return true;
              return false;
              

              There is also a bug in IE5.5 SP0 and 1 where saving a document using the file download
              dialogue can indeed result in the HTML of the active frame being saved instead
              of the document.
              You can get IE 5.5 SP2 fix here:
              http://www.microsoft.com/windows/ie/download/ie55sp2.htm
              "Cameron Purdy" <[email protected]> wrote:
              >Hi Tom,
              >
              >I looked over the code. I think the problem is caused by the fact that
              >you
              >are doing a POST instead of a GET. IE doesn't GET anything back (OK,
              >I'm
              >totally technically wrong, but read the early HTTP specs and you'll see
              >the
              >"intent" of what I'm saying) so it just saves the current document. That's
              >my guess. Change to GET and it should work, since IE will know to save
              >the
              >incoming document.
              >
              >FWIW - You will often get more performance using a buffer of some sort
              >between your looping/writing and the response's stream.
              >
              >Peace,
              >
              >--
              >Cameron Purdy
              >Tangosol Inc.
              ><< Tangosol Server: How Weblogic applications are customized >>
              ><< Download now from http://www.tangosol.com/download.jsp >>
              >
              >
              >"Tom Gerber" <[email protected]> wrote in message
              >news:[email protected]...
              >> I have a servlet which needs to return a data stream that the browser
              >> shoule save as a file on the users local hard drive.
              >>
              >> My servlet seems to work just fine with Netscape 4.7 but IE always
              >saves
              >> the original HTML Form page that called the Servlet.
              >>
              >> Is there a bug in WL/IE or am I doing something stupid
              >>
              >> here's my code - the method doing returning the data is the last one
              >in
              >> this code - getResponseFromDispatch()
              >>
              >> Thanks
              >>
              >> Tom
              >>
              >> package com.nexterna.optiform.server.b2b;
              >>
              >> import javax.servlet.*;
              >> import javax.servlet.http.*;
              >> import java.io.*;
              >> import java.util.*;
              >> import javax.naming.*;
              >>
              >> import org.apache.log4j.Category;
              >> import org.apache.log4j.PropertyConfigurator;
              >> import org.w3c.tools.codec.Base64Encoder;
              >>
              >> import com.nexterna.optiform.server.ejb.dispatcher.*;
              >> import com.nexterna.optiform.common.*;
              >> import com.nexterna.ejb.usermanager.*;
              >> import com.nexterna.common.security.*;
              >> /**
              >> * Title: B2BInterfaces
              >> * Description:
              >> * Copyright: Copyright (c) 2001
              >> * Company:
              >> * @author
              >> * @version 1.0
              >> */
              >>
              >> public class ExportResponseAsXML extends HttpServlet {
              >> private static final String CONTENT_TYPE = "text/html";
              >> /**Initialize global variables*/
              >> private Context jndiContext = null;
              >> private String poolName = "";
              >> private String providerURL = "";
              >> private String icf = "";
              >> private String command = null;
              >> private DispatcherServices dispatcher = null;
              >> private UserManager usermgr = null;
              >> private String ccode = "b2b.9284s3a41";
              >>
              >> private static Category cat =
              >> Category.getInstance(ExportResponseAsXML.class.getName());
              >>
              >> public void init(ServletConfig config) throws ServletException {
              >> super.init(config);
              >>
              >> try {
              >> InitialContext ic = new InitialContext();
              >> Context environment = (Context) ic.lookup("java:comp/env");
              >>
              >> PropertyConfigurator.configure(
              >> config.getInitParameter("LOG4J"));
              >> poolName =
              >> config.getInitParameter("POOLNAME");
              >> providerURL = config.getInitParameter("PROVIDER_URL");
              >> icf = config.getInitParameter("INITIAL_CONTEXT_FACTORY");
              >> }
              >> catch (NamingException e) {
              >> cat.error("Exception in EJBCreate trying to lookup
              >> initializations");
              >> cat.error("Servlet Failed Initialization " + poolName +
              >":"
              >> + providerURL + ":" + icf);
              >> cat.error(e);
              >> }
              >>
              >> getDispatchServices();
              >> getUserManager();
              >>
              >> if (cat.isDebugEnabled()) {
              >> cat.debug("Servlet Initialized " + poolName + ":" +
              >> providerURL + ":" + icf);
              >> }
              >>
              >> }
              >> /**Process the HTTP Get request*/
              >> public void doGet(HttpServletRequest request, HttpServletResponse
              >> response) throws ServletException, IOException {
              >> response.setContentType(CONTENT_TYPE);
              >> PrintWriter out = response.getWriter();
              >> out.println("<html>");
              >> out.println("<head><title>ExportResponseAsXML</title></head>");
              >> out.println("<body>");
              >> out.println("<p>The servlet has received a GET. This is the
              >> reply.</p>");
              >> out.println("</body></html>");
              >> }
              >> /**Process the HTTP Post request*/
              >> public void doPost(HttpServletRequest request, HttpServletResponse
              >> response)
              >> throws ServletException, IOException {
              >>
              >> // first we need to get the user-id/password and create a user
              >profile
              >> Base64Encoder b = new
              >Base64Encoder(request.getParameter("passwd"));
              >> String pass = b.processString();
              >>
              >> if (usermgr == null)
              >> log("User manager is null!");
              >>
              >> UserProfile up = usermgr.getUserProfile(
              >> request.getParameter("userid").toUpperCase(), pass);
              >>
              >> if ((up == null) ||
              >> (!ccode.startsWith(request.getParameter("controlcode"))))
              >{
              >> response.setContentType("text/html");
              >> PrintWriter out = response.getWriter();
              >> out.println("<html>");
              >> out.println("<head><title>ExportResponse</title></head>");
              >> out.println("<body>");
              >> out.println("<p>Incorrect parameters");
              >> out.println("</body></html>");
              >> cat.error("incorrect parameters: " + up + " : " +
              >> request.getParameter("controlcode"));
              >> }
              >> else {
              >>
              >> // there are 3 ways to export responses
              >> // 1. via the dispath id
              >> // 2. via the response id
              >> // 3. vis the form name and last retrieved date
              >> // the third one allows you to get all new responses for a
              >form
              >> type
              >> // and for a time period.
              >> String rid = request.getParameter("rid");
              >> String did = request.getParameter("did");
              >> String formname = request.getParameter("formname");
              >> String date = request.getParameter("datefrom");
              >> boolean failed = false;
              >> if (cat.isDebugEnabled()) {
              >> cat.debug("rid " + rid);
              >> cat.debug("did " + did);
              >> cat.debug("formname " + formname);
              >> cat.debug("datefrom " + date);
              >> }
              >> if (did != null)
              >> failed = getResponseFromDispatch(response, did);
              >>
              >> else if (rid != null)
              >> //failed = getResponse(response, rid);
              >> System.out.println("temp");
              >>
              >> else if (formname != null && date != null)
              >> //failed = getAllResponses(response, formname, date);
              >> System.out.println("temp");
              >>
              >> else {
              >> response.setContentType(CONTENT_TYPE);
              >> PrintWriter out = response.getWriter();
              >> out.println("<html>");
              >> out.println("<head><title>ExportResponseAsXML</title></head>");
              >> out.println("<body>");
              >> out.println("<p>No Responses available.</p>");
              >> out.println("</body></html>");
              >> }
              >>
              >> if (failed) {
              >> response.setContentType(CONTENT_TYPE);
              >> PrintWriter out = response.getWriter();
              >> out.println("<html>");
              >> out.println("<head><title>ExportResponseAsXML</title></head>");
              >> out.println("<body>");
              >> out.println("<p>No Responses available due to error.</p>");
              >> out.println("</body></html>");
              >> }
              >>
              >> }
              >> }
              >> /**Clean up resources*/
              >> public void destroy() {
              >> }
              >>
              >> protected static Context getInitialContext(String purl, String picf)
              >> throws javax.naming.NamingException{
              >>
              >> cat.debug("URL: " + purl);
              >> cat.debug("Initial_context_factory: " + picf);
              >> Properties p = new Properties();
              >> // ... Specify the JNDI properties specific to the vendor.
              >> p.put(Context.INITIAL_CONTEXT_FACTORY, picf);
              >> p.put(Context.PROVIDER_URL, purl);
              >> return new javax.naming.InitialContext(p);
              >> }
              >>
              >>
              >> protected void getDispatchServices() {
              >> DispatcherServicesHome home = null;
              >> try {
              >>
              >> //if (jndiContext == null)
              >> //{
              >> cat.debug("trying to get jndi - dispatcher");
              >> jndiContext = getInitialContext(providerURL, icf);
              >> //}
              >>
              >> cat.debug("doing lookup - dispatcher");
              >> Object obj = jndiContext.lookup("nexterna.DispatcherServices");
              >> cat.debug("getting home ref - dispatcher");
              >> home = (DispatcherServicesHome)
              >> javax.rmi.PortableRemoteObject.narrow(
              >> obj, DispatcherServicesHome.class);
              >> }
              >> catch (javax.naming.NamingException ne)
              >> {
              >> cat.error(ne);
              >> }
              >>
              >> catch (Exception e)
              >> {
              >> cat.error(e);
              >> };
              >>
              >> try {
              >> cat.debug("home.create - dispatcher");
              >> dispatcher = home.create();
              >> }
              >> catch (javax.ejb.CreateException ce)
              >> {
              >> cat.error(ce);
              >> }
              >> catch (java.rmi.RemoteException re)
              >> {
              >> cat.error(re);
              >> }
              >> catch (Exception e)
              >> {
              >> cat.error(e);
              >> };
              >> }
              >>
              >> protected void getUserManager() {
              >> UserManagerHome home = null;
              >> try {
              >>
              >> if (jndiContext == null)
              >> {
              >> cat.debug("trying to get jndi - usermanager");
              >> jndiContext = getInitialContext(providerURL, icf);
              >> }
              >>
              >> cat.debug("doing lookup - usermanager");
              >> Object obj = jndiContext.lookup("nexterna.UserManager");
              >> cat.debug("getting home ref - usermanager");
              >> home = (UserManagerHome) javax.rmi.PortableRemoteObject.narrow(
              >> obj, UserManagerHome.class);
              >> }
              >> catch (javax.naming.NamingException ne)
              >> {
              >> cat.error(ne);
              >> }
              >>
              >> catch (Exception e)
              >> {
              >> cat.error(e);
              >> };
              >>
              >> try {
              >> cat.debug("home.create - usermanager");
              >> usermgr = home.create();
              >> }
              >> catch (javax.ejb.CreateException ce)
              >> {
              >> cat.error(ce);
              >> }
              >> catch (java.rmi.RemoteException re)
              >> {
              >> cat.error(re);
              >> }
              >> catch (Exception e)
              >> {
              >> cat.error(e);
              >> };
              >> }
              >>
              >> protected boolean getResponseFromDispatch(HttpServletResponse resp,
              >> String id) {
              >>
              >> String s = null;
              >> try {
              >> //before we will export responses to a dispatch, the dispatch
              >> must be complete
              >> s = dispatcher.getDispatchStatusString(id);
              >> }
              >> catch (java.rmi.RemoteException e)
              >> {
              >> cat.error(e);
              >> return true;
              >> }
              >>
              >> if (s.compareToIgnoreCase("Completed") != 0) {
              >> cat.debug("Dispatch status is not COMPLETED. Cannot export
              >> responses");
              >> return true;
              >> }
              >>
              >> resp.setContentType("application/RFC822");
              >> resp.setHeader("Content-Type", "application/RFC822"); // set
              >both
              >> ways to be safe
              >> resp.setHeader("Content-disposition",
              >> "attachment; filename=\"" + id + ".txt\"");
              >> cat.debug("Setting headers");
              >> cat.debug("Content-disposition",
              >> "attachment; filename=\"" + id + ".txt\"");
              >>
              >> HashMap responses = null;
              >> try {
              >> responses = dispatcher.getResponses(id,
              >> DispatcherServices.DISPATCH_ID);
              >> }
              >> catch (java.rmi.RemoteException e)
              >> {
              >> cat.error(e);
              >> return true;
              >> }
              >>
              >> try {
              >> ServletOutputStream os = resp.getOutputStream();
              >> Iterator i = responses.values().iterator();
              >> while (i.hasNext()) {
              >> Object o = i.next();
              >> os.print(o.toString());
              >> cat.debug("Writing XML");
              >> cat.debug(o.toString());
              >> }
              >> os.flush();
              >> os.close();
              >> }
              >> catch (Exception e)
              >> {
              >> cat.error(e);
              >> return true;
              >> }
              >>
              >> return false;
              >> }
              >>
              >
              >
              

Maybe you are looking for