Missing the content when saving HTML from JEditorPane.write(..)

hi,
i m trying to develop html editor using JEditorPane. the document type used is HTMLDocument and HTMLEditorKit. when I try to save using the following function:
try{
FileWriter     w = new FileWriter("doc.html");
//HTMLEditorKit edi = (HTMLEditorKit)editorPane.getEditorKit();
EditorKit edi = editorPane.getEditorKit();
//StyledEditorKit edi = new StyledEditorKit();
//edi.write(w, (StyledDocument)editorPane.getDocument(), 0, editorPane.getDocument().getLength());
editorPane.write(w);
w.close();
}catch(Exception de){System.out.println(de);
}all the contents are missing, only the tags are intact in the output file doc.html. I am using JDK 1.4.2
anybody can help me? thank you very much

here is the code. hehe sorry lol it took me sometime to take off all the function. please try to type something and then save. only the update is saved but the default heading (well in this case, i have replace them all with a "something must be here". thank you very much
// HTMLEditor.java
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import java.awt.event.*;
import java.awt.*;
import java.io.*;
public class HTMLEditor extends JFrame{
  private JTextComponent textComp;
  public static void main(String[] args) {
    HTMLEditor editor = new HTMLEditor();
    editor.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    editor.setVisible(true);
  public HTMLEditor() {
    super("Swing Editor");
    textComp = createTextComponent();
    Container content = getContentPane();
    content.add(textComp, BorderLayout.CENTER);
    content.add(createToolBar(), BorderLayout.NORTH);
    setSize(320, 240);
    Template t = new Template((HTMLDocument)(textComp.getDocument()));
    t.setupTemplate();
  // Override to create a JEditorPane with the HTMLEditorKit in place
  protected JTextComponent createTextComponent() {
    JEditorPane jep = new JEditorPane();
    jep.setEditorKit(new HTMLEditorKit2());
    JEditorPane.registerEditorKitForContentType
     ("text/html", "HTMLEditorKit2");
    return jep;
  protected JTextComponent getTextComponent() { return textComp; }
  // Add HTML actions to the toolbar
  protected JToolBar createToolBar() {
    JToolBar bar = new JToolBar();
    bar.addSeparator();
    bar.add(new StyledEditorKit.BoldAction());
    bar.add(new SaveAction());
    return bar;
  class SaveAction extends AbstractAction {
    public SaveAction() {
      super("Save", new ImageIcon("icons/save.gif"));
    // Query user for a filename and attempt to open and write the text
    // components content to the file
    public void actionPerformed(ActionEvent ev) {
      JFileChooser chooser = new JFileChooser();
      if (chooser.showSaveDialog(HTMLEditor.this) !=
          JFileChooser.APPROVE_OPTION)
        return;
      File file = chooser.getSelectedFile();
      if (file == null)
        return;
      FileWriter writer = null;
      try {
        writer = new FileWriter(file);
        textComp.write(writer);
      catch (IOException ex) {
        JOptionPane.showMessageDialog(HTMLEditor.this,
        "File Not Saved", "ERROR", JOptionPane.ERROR_MESSAGE);
      finally {
        if (writer != null) {
          try {
            writer.close();
          } catch (IOException x) {}
  class HTMLEditorKit2 extends HTMLEditorKit{
       public Document createDefaultDocument(){
         HTMLDocument doc = new HTMLDocument();;
         doc.setAsynchronousLoadPriority(-1); // load synchronously
         return doc;
class Template{
     HTMLDocument doc;
     StyleContext styles = new StyleContext();
     public Template(HTMLDocument doc){
          this.doc= doc;
          Style def = styles.getStyle(StyleContext.DEFAULT_STYLE);
         Style heading = styles.addStyle("heading", def);
         StyleConstants.setFontFamily(heading, "SansSerif");
         StyleConstants.setBold(heading, true);
         StyleConstants.setAlignment(heading, StyleConstants.ALIGN_CENTER);
         StyleConstants.setSpaceAbove(heading, 10);
         StyleConstants.setSpaceBelow(heading, 10);
         StyleConstants.setFontSize(heading, 18);
     public void setupTemplate(){
          Style s = styles.getStyle("heading");
          try{
               doc.insertString(doc.getLength(), "Something must be here", s);
               doc.insertString(doc.getLength(), "\n", null);
                doc.setLogicalStyle(doc.getLength() - 1, s);
          }catch(Exception e){}     
}

Similar Messages

  • When saving files from the internet, why doesn't Firefox 'know' to put .jpg files in "Photos" and pdf files in "Documents"?

    When saving files from the internet, why doesn't Firefox 'know' to put .jpg files in "Photos" and pdf files in "Documents"? IE always saved photos in the "Photos" file and documents in the "Documents" file. Firefox makes me choose every time. Very annoying.

    How about if Firefox is programmed like IE in this ONE thing...
    When saving files from internet sources, if the file ends in a typical photo extension such as .jpg, .bmp, .tif etc. it defaults to save it in your PHOTOS folder.
    When saving anything like a .doc, .pdf etc. it defaults to save it to your DOCUMENTS.
    You could still change it to 'desktop' if that if really where you want all your photos and documents... or some other folder that you decide, but DEFAULTS to the LOGICAL folder.
    I have carpal tunnel SO bad that even typing this suggestion is painful and having to make the extra click along with moving the mouse EVERY time I want to save something is painful.
    ALSO, I shouldn't need a bunch of ADDONS to accomplish this. I tried downloading one and it did nothing. The problem still exists.

  • WCF returning "The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)"

    I have a WCF service I am trying to run on a new installation of 64-bit Windows Server 2008 IIS. Although it runs fine on Windows 2003 IIS, it is throwing the error in the thread title, which appears to be a server config issue, but I am not sure. Googling and searching the MSDN forums did not turn up a solution. I tried running WCF Logging, but that didn't help either.
    Does anyone have any suggestions on how to solve this probelm?
    Here is the error:
    The content type text/html of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <title>500 - Internal server error.</title>
    <style type="text/css">

    I have the same issue on Windows 7 machine. The service works fine using a SoapUI client but a .Net client faisl to get a response.
    Hi,
    I have a WCF service which works perfectly when using SoapUI but throws error in my .Net client.
    {"The content type text/html; charset=UTF-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first
    1024 bytes of the response were: '<HTML><HEAD><link rel=\"alternate\" type=\"text/xml\" href=\"http://xyz.mysite.com/ysa/Broker.svc?disco\"/><STYLE type=\"text/css\">#content{ FONT-SIZE: 0.7em;
    PADDING-BOTTOM: 2em; MARGIN-LEFT: 30px}BODY{MARGIN-TOP: 0px; MARGIN-LEFT: 0px; COLOR: #000000; FONT-FAMILY: Verdana; BACKGROUND-COLOR: white}P{MARGIN-TOP: 0px; MARGIN-BOTTOM: 12px; COLOR: #000000; FONT-FAMILY: Verdana}PRE{BORDER-RIGHT: #f0f0e0 1px solid; PADDING-RIGHT:
    5px; BORDER-TOP: #f0f0e0 1px solid; MARGIN-TOP: -5px; PADDING-LEFT: 5px; FONT-SIZE: 1.2em; PADDING-BOTTOM: 5px; BORDER-LEFT: #f0f0e0 1px solid; PADDING-TOP: 5px; BORDER-BOTTOM: #f0f0e0 1px solid; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e5e5cc}.heading1{MARGIN-TOP:
    0px; PADDING-LEFT: 15px; FONT-WEIGHT: normal; FONT-SIZE: 26px; MARGIN-BOTTOM: 0px; PADDING-BOTTOM: 3px; MARGIN-LEFT: -30px; WIDTH: 100%; COLOR: #ffffff; PADDING-TOP: 10px; FONT-FAMILY: Tahoma; BACKGROUND-COLOR: #003366}.intro{MARGIN-LEFT: -15px}</STYLE><TITLE>Broker
    Service</TITLE></HEAD><BODY><DIV id=\"content\"><P class=\"head'."}
    I have the same service hosted on my local machine and when I point to the local service I can execute the operation with no issues. The message encoding is Soap11. I tried changing to Soap12 but I get exact same error. Any ideas greatly appreciated.
    I do have windows Activation Features installed and I am using .Net Framework 4.
    Thanks
    Sofia Khatoon

  • Modify the contents in Dynamic HTML

    Hi friends,
    I want to modify the contents in a HTML page. This page is dynamically generated from some JSP. First of all, is it possible to modify the content in a HTML page that was generated at run time. If so, Pls. give me an example of the same.
    Tons of thanks in advance....
    SIVA

    Here's an example:
    You have a JSP page that has a form tag called myForm.
    You have a textfield named 'textField1' in the form.
    You have a button on the form with an onClick event, in the javascript
    function that is called for the onClick, you can change
    the contents of the textfield by writing something like this:
    document.myForm.textField1.value="new contents";
    For further information on this, I suggest reading up on Javascript. One book on this is 'Javascript, the definitive guide".

  • Sharepoint error - Search Issue - The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1).

    i see this error everywhere - In ULS logs, on site. On the site > Site settings > search keywords; I see this - 
    The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (application/soap+msbin1). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>IIS 7.0 Detailed Error - 500.19 - Internal Server Error</title> <style type="text/css"> <!-- body{margin:0;font-size:.7em;font-family:Verdana,Arial,Helvetica,sans-serif;background:#CBE1EF;} code{margin:0;color:#006600;font-size:1.1em;font-weight:bold;} .config_source code{font-size:.8em;color:#000000;} pre{margin:0;font-size:1.4em;word-wrap:break-word;} ul,ol{margin:10px 0 10px 40px;} ul.first,ol.first{margin-top:5px;} fieldset{padding:0 15px 10px 15px;} .summary-container fieldset{padding-bottom:5px;margin-top:4px;} legend.no-expand-all{padding:2px 15px 4px 10px;margin:0 0 0 -12px;} legend{color:#333333;padding:4px 15px 4px 10px;margin:4px 0 8px -12px;_margin-top:0px; border-top:1px solid #EDEDED;border-left:1px solid #EDEDED;border-right:1px solid #969696; border-bottom:1px solid #969696;background:#E7ECF0;font-weight:bold;'.
    I am facing issues in searching, my managed metadata service is not running, search results page throws internal error. Any Idea why this above error comes.
    P.S: We use windows authentication in our environment.

    Hi IMSunny,
    It seems you have solved this issue based on your another post.
    http://social.technet.microsoft.com/Forums/en-US/aa468ab0-1242-4ba8-97ea-1a3eb0c525c0/search-results-page-throws-internal-server-error?forum=sharepointgeneralprevious
    Thanks
    Daniel Yang
    TechNet Community Support

  • HT1498 Hi, Is it possible to change the language when renting movies from apple TV?

    Hi, Is it possible to change the language when renting movies from apple TV?

    It depends on how the java code is gnerated. If for example months are given with fixed array .... then it will only be english
    But then agin you have the source code (.java files) open all java files in the oracle.forms froject and alter to your language then recompile and reacreate the jar (easily done with Jdeveloper)

  • I missed the second day free application from itune 12 Days of Gifts.  Where can I download again.  What was the second day free application ?

    I missed the second day free application from itune 12 Days of Gifts.  Where can I download again.  What was the second day free application ?

    Yesterday's app here in the UK still appears to be free (at the moment) to download (I don't know what the app's normal price is) : Score! Classic Goals. If it's not free in your country's store then if you want you will need to buy it.

  • How can you keep the highest iphone 4s Video quality the same when exporting it from iMovie.

    How can you keep the highest iphone 4s Video quality the same when exporting it from iMovie.

    InDesign's PDF export engine does not transcode your videos, they are embedded exactly as they were in the original file. The Flash Player runtime which displays video inside PDF files may not show a perfect match to Quicktime etc. because most video playback tools aren't designed for a color-calibrated workflow, but they should be close.
    The playback quality (blocking and aliasing) will be affected if the clip is not playing at 100% (screen pixels != video pixels) and in PDFs with the standard video player widget, that will only ever happen when you use 'floating window' mode. PDF pages have physical dimensions, so viewing them at "100%" does not make them match screen pixels.
    If you don't mind the video clip being smaller than the media annotation in which it's playing, then use my free upgrade to the Acrobat playback widget - VideoPlayerX - which maintains 1:1 pixel scale until the page is zoomed out too far for it to fit. You can install the widget into InDesign so it's used by default when exporting.

  • HT1435 how long does the recycle program take or do they give you an ipod straight away when you are at the store.when you buy from the store do they do free ipod engraving

    how long does the recycle program take or do they give you an ipod straight away when you are at the store.when you buy from the store do they do free ipod engraving

    How recently did you switch?  If it's less than 60 days, then Verizon simply reinstates your previous account.  The fact that you were on the EDGE plan and mailed the devices back, and they apparently are somewhere in the system, could cause complications, and it might just work out that you just go back on the same plan and they set you up with the same devices.  I'm not sure how it will go - but since you are still being billed for the devices... 

  • How To Fetch the Content of a File from Client's PC?

    In my JSP I have this:
         <input type="file" name="filename">for visitors of the web page to browse their PCs' directories to select a file to upload (when the Submit button is clicked).
    What appears in the text field will be a file name. How do I get both the file name and the content of that file to be saved in the database?

    From http://www.htmlhelp.com/reference/html40/forms/input.html:
    A form that includes a file INPUT must specify METHOD=post and ENCTYPE="multipart/form-data" in the <FORM> tag. CGI libraries such as CGI.pm allow simple handling of such forms.
    Form-based file upload is unsupported by many currently deployed browsers. Authors should provide alternative methods of input where possible.
    The following example allows the user to upload an HTML document for validation:
    <FORM METHOD=post ACTION="/cgi-bin/validate.cgi" ENCTYPE="multipart/form-data">
    <P>Select an HTML document to upload and validate. If your browser does not support form-based file upload, use one of our alternate methods of validation.</P>
    <P><INPUT TYPE=file NAME="html_file" ACCEPT="text/html"></P>
    <P><INPUT TYPE=submit VALUE="Validate it!"></P>
    </FORM>
    Your servlet would then have to process whatever data is put into that parameter. You can look at O'Reilly's servlet utilities, or one of the other other links here:
    http://www.google.com/search?q=java+servlet+file+upload&sourceid=opera&num=0&ie=utf-8&oe=utf-8

  • How to read the contents of a file from batch file

    Hi
    I have a text file which contains exe files.  I need to read those exe file names and then execute the same in order they occur. Sample content of the text file a.txt is as below.
    "If you are looking at previous version then use 8792xINT.EXE if you are looking for the current version then check 8793xINT.exe
    please use README.TXT file before you use any above files" 
    I need to read and execute 8793xINT.exe from above text in batch file.  Here number 8793 is variable changes as version changes but xINT.exe is constant.
    Thank you in advance
    DBC
    DBC

    Sorry... 
    code i use is here -
    strScriptFile = Wscript.ScriptFullName ' C:\Patch\test_download3.vbs
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.GetFile(strScriptFile)
    strFolder = objFSO.GetParentFolderName(objFile) 
    Set objShell = CreateObject("WScript.Shell")
    strLink = "http://dbc.download.com/patches/" 
    strSaveTo = "C:\patches"
    objShell.CurrentDirectory = strSaveTo
    objShell.Run Quotes(strFolder & "\wget.exe") & " " & Quotes(strLink) & " -N",1,True
    objShell.CurrentDirectory = strFolder
    Function Quotes(strQuotes)
    Quotes = chr(34) & strQuotes & chr(34)
    End Function
    the above code geneates index.html.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
     <HEAD>
      <TITLE>Index of /140410/patches/</TITLE>
     </HEAD>
     <BODY>
    <H1>Index of /140410/patches/</H1>
    <PRE>   <A HREF="?N=D">Name</A>                              <A HREF="?M=A">Last modified</A>        <A
    HREF="?S=A">Size</A>  
    <HR>
    <IMG SRC="/icons/dir.gif" ALT="[DIR]"> <A HREF="..">Parent Directory</A>                  12-Oct-2014 16:25     1k  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="8792KB.exe">8792KB.exe</A>                      18-Oct-2014 1:19  6.4M  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="8793KB.exe">8793KB.exe</A>                      18-Oct-2014 2:19  4.2M  
    <IMG SRC="/icons/dir.gif" ALT="[FILE]"> <A HREF="2834KB.exe">2834KB.exe</A>                      20-Oct-2014 16:18  2.5M  
    <IMG SRC="/icons/dir.gif" ALT="[DIR]"> <A HREF="extra/">extra/</A>                            17-Sep-2013 23:09     1k  
    <IMG SRC="/icons/generic.gif" ALT="[FILE]"> <A HREF="readme.txt">readme.txt</A>                        30-Jan-2012 11:54    20k  
    </PRE><HR>
    </BODY></HTML>
    From above generated index file and re run the above script to in loop to download the exe files in c:\patches and deploy the same with schedule task on the PC in our Isolated ODC. Number of exe files this time only 3 exe.  I am using counter to loop
    the down load. 

  • Can i get the content of a HTML tag?

    I would like knowing if it is possible,
    instead of getting all the document where the searched string is found,
    i can get only the content of a tag
    in other words, I have defined the following index:
    CTX_DDL.CREATE_SECTION_GROUP('htmlgroup', 'HTML_SECTION_GROUP');
    CTX_DDL.ADD_ZONE_SECTION('htmlgroup', 'titulo', 'TITLE');
    CREATE INDEX index_string ON table(field_to_indexing)
    INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('SECTION GROUP htmlgroup');
    SELECT field FROM table WHERE CONTAINS('searching string' WITHIN titulo) > 0;
    The index works just fine and makes the searching correctly, but it returns back the whole document,
    and I wanted it to return just the content of the TITLE tag. I would like to know if this is possible.

    It is possible if you are using the XMLType operators available in 9i. A short article describe this approach http://otn.oracle.com/products/oracle9i/daily/nov30.html
    Now, if you are not using 9i you can still do it but at the application level. You need to get a "chunk" of the document and then perform
    substring searching to extract the content of the title tag.
    I would like knowing if it is possible,
    instead of getting all the document where the searched string is found,
    i can get only the content of a tag
    in other words, I have defined the following index:
    CTX_DDL.CREATE_SECTION_GROUP('htmlgroup', 'HTML_SECTION_GROUP');
    CTX_DDL.ADD_ZONE_SECTION('htmlgroup', 'titulo', 'TITLE');
    CREATE INDEX index_string ON table(field_to_indexing)
    INDEXTYPE IS CTXSYS.CONTEXT PARAMETERS ('SECTION GROUP htmlgroup');
    SELECT field FROM table WHERE CONTAINS('searching string' WITHIN titulo) > 0;
    The index works just fine and makes the searching correctly, but it returns back the whole document,
    and I wanted it to return just the content of the TITLE tag. I would like to know if this is possible.

  • Rendering the content of a blob from discoverer

    Hi Gurus,
    I've got to render, on the web browser, the contents of a blob stored in a table. I don't know, at design time, the type/mime of the blob's content, It's actually stored aside the blob in another column of the same table.
    It could be sufficent, for me, presenting a link and asking the user to click on it.
    What's the way I can realize this?
    Thanks in advance
    Norberto
    PS: My skill is mainly on forms/reports... I'm not an ace in Discoverer technology...

    Hi,
    You have got 2 options here. You can create a data item for each mime type and have a column for each mime type in the report. Each row would have a link in one of the columns. You will have to create a view or custom folder over your blob table with additional columns for each mime type, for example to create an extra column for Excel:
    SELECT ...,
    CASE WHEN mime_type = 'application/vnd.ms-excel' THEN blob_content END blob_exel
    FROM blob_table
    Then set the content_type in the properties of the folder to be XLS for blob_excel column. The user would then have to click on the column which had been populated with the link.
    The other option is to write your own mod_plsql procedure to download the blob. It is quite simple, you need to call owa_util.mime_header to set the mime type and wpg_docload.download_file to download the blob. You then create a hyperlink to your mod_plsql procedure.
    Hope that helps,
    Rod West

  • SP23 missing BI content when processing EWA data

    Hello,
    In a recently upgraded solman system i am trying to process downloaded EWA data. For this a batch job SM:EXEC SERVICES is scheduled.
    This job cancels however with message InfoCube 0SMD_PE2D is not available in version A.
    When I search for this infocube in RSA1 i do not find it, so it seems I am missing some content.
    Is this true? Or am i doing something wrong here?. Do I need to activate some ehp1 funtionality for this?
    Thanks for any help
    Tom

    >
    Tom van Rooyen wrote:
    > One error at least was that in SOLMAN_SETUP the BI activation failed because the myself source system was not present at the time. Still the job went technically OK, which is not good practise
    Tom,
    Could you please open a separate thread in SDN or open a customer message on SV-SMG-INS to discuss the expected behavior within SOLMAN_SETUP.
    I would also appreciate to avoid running into issues during EWA processing. Detection should have been possible earlier for users.
    Thanks,
    Ruediger

  • Transaction ID when saved transaction from web ui

    Hi,
    After implementation of support package SAPKU70210, when we saved incidents from web ui the "transaction id" does not appear in message:
    Before SP: " Transaction 3100007471 saved"
    After SP: "Transaction  saved"
    Please, any idea?
    Thanks in advanced.

    Hello,
    Check if Note 1944322 helps.
    Regards,
    Ashik

Maybe you are looking for

  • Recurring Hard Drive Errors/Crashes After Replacing Repeatedly

    I've got a 2007 2GHz Macbook. I've been having repeated hard drive errors for the past few months. First the original hard drive went 100% dead. I replaced it with a Hitachi 350 Gig. After repeated serious hard drive crashes and reformats, I replaced

  • Can't delete trash because items are locked, but I can't find them

    When I used the mac backup software, it backed up EVERYTHING including applications and settings, etc. After I lost my harddrive, I replaced it from my external harddrive, but it put things on my computer that were already there on my new hard drive,

  • All MIDI programs broken

    Since installing this update (10.5.3), neither GarageBand or Logic Pro 8 receive any input from my MIDI controller. Everything worked fine before the update. In addition GarageBand refuses to quit and has to be force quit. After that the whole machin

  • Logitech V470 Cordless Laser Mouse stopped working!

    Hi I have a Logitech V470 Cordless Laser Mouse... Now I can't get it to work in Mac OS. I have VMWare, and it works fine in Windows... I really don't know how to fix this... it seems that the mouse is not found... Any ideas? Thank you Pedro

  • Tecra 8200: I can't install Wlan driver for Windows XP

    Hello , i can't find wireless driver for windows xp. I have Tecra 8200. I try to install a lot of drivers of the official page of Toshiba for Tecra 8200 but the drivers do not work. If anyone know how i can install wireless in my tecra 8200, please l