Abstract Portal Component: How to inclue a HTML file into the response?

Hi experts,
i am currently working on the problem, that i want to access KM inside my AbstractPortalComponent in order to retrieve a HTML File.Afterwars i want to include this file into my IPortalComponentResponse.
IPortalComponentResponse offers the method include(IPortalComponentResponse , IResource)
Is it possible to use this method to achieve my goal?
I have tried this approach:
IResourceContext resourceContext = new ResourceContext(requester);
RID rid = RID.getRID("/documents/test.gif");
IResource resource = ResourceFactory.getInstance().getResource(rid,resourceContext);
response.include(request,resource);
But the problem is that this IResource doesn't match the IResource that is needed for this method.
My IResource belongs to com.sapportals.wcm.repository.IResource
But the Methos just works with com.sapportals.portal.prt.resource.IResource
So can you help me on this one?:)
With Best Regards
Marcus

Hi,
read the contents of the resource and put them to the output.
Dumb but working piece of code:
private String renderResource(IResource resource, boolean html) {
          StringBuffer buf = new StringBuffer("");
          try {
               IContent content = resource.getUnfilteredContent();
               if (content != null) {
                    InputStream is = content.getInputStream();
                    byte[] bytes = new byte[(int) content.getContentLength()];
                    int i = is.read();
                    int count = 0;
                    while (i != -1) {
                         char b = (char) i;
                         bytes[count] = (byte) i;
                         count++;
                         i = is.read();
                    buf.append(new String(bytes, "UTF-8"));
                    if (html) {
                         buf.append("</br>");
                    } else {
                         buf.append('\n');
          } catch (Exception e) {
// do something
          return buf.toString();
hope this helps,
Rmano

Similar Messages

  • How to put an HTML file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this source code to Jeditor pane.
    Thanks
    Srikant

    hi srikkant,
    ur html code is inside the source code..? are you working on applets..? if ur html file can be read as a file and the file stream can converted to a string and put into a Jeditor pane using the setText() method. for editing HTML text a editor called javax.swing.text.html.HTMLEditorKit can be used.
    Refer to JAVA API for further clarifiactions and examples.

  • How to add a html file into JEditorPane

    Hi
    I am doing an aplication on swing.But I don't know how to add a html file to the JeditorPane keeping the html file on the source code. i.e my html file is in my source code.Then how to add this html file to Jeditor pane.
    Thanks
    Srikant

    QuickTime requires player and plugins that most people don't have.  You'll reach a much wider audience if you use HTML5 <video> with mp4, webm and ogg files.
    <!doctype html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>HTML5 with Video</title>
    <!--help for older IE browsers-->
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    </head>
    <style>
    video {
        max-width:100%;
        display:block;
        margin:0 auto;
    </style>
    <body>
    <h2>Use 3 File Types to support all browsers &amp; mobile devices:  MP4, WEBM and OGV.</h2>
    <h3>Online Video Converter
    http://video.online-convert.com/</h3>
    <!--begin video-->
    <video controls poster="Your_poster_image.jpg">
    <!--these are 6 sec sample videos for testing purposes. Replace sample-videos with your own files-->
    <source src="http://techslides.com/demos/sample-videos/small.webm" type="video/webm">
    <source src="http://techslides.com/demos/sample-videos/small.ogv" type="video/ogg">
    <source src="http://techslides.com/demos/sample-videos/small.mp4" type="video/mp4">
    If you're seeing this, you're using an
    outdated browser that doesn't support
    the video tag. </video>
    <!--end video-->
    </body>
    </html>
    Nancy O.

  • How to import jar & exp file into the eclipse 3.1 + jcop

    hi, I am new to the javacard technology.
    I have implementing applet by using eclipse 3.1 + jcop plugin.
    recentlly, i got jar and exp file from someone. and I have to import given two files in the my applet.
    Q1. but i don't know how to use(import) two files into the elipse.
    and...
    I have tried to put the export file structure in the build path, but I am still getting the same error:
    Q2. "resolving constant-pool of clazz cash/ccash; failed: no such clazz cash/ccash;", what means?
    anyone help me~plz!
    many thanks..
    lsh.
    Message was edited by:
    neonoble

    1) In the Package explorer right-click the project you want to import the jar files into.
    2) Click import
    3) Select Archive file in the Import dialog box and click next
    4) Browse to the jar file and select it
    Socx

  • How do I get my file into the time line in Premiere Pro CC?

    How do I get my file into the time line in Premiere Pro CC? I am use to Premier Pro CS6 and unfortunately my labtop took a crash and I lost all of my adobe products. I wanted to check out a trial version and I cannot seem to find one for CS6! Please Help Me! My project is due tonight!!!!!

    Hi Aneumann,
    Welcome to the Forums.
    You have to just right click on the clip imported, in the project panel and select new sequence from clip. You can also go to file menu>new>sequence and create a sequence and then drag the clips after importing them , into the timeline.
    Regards,
    Vinay

  • How to sent importet RAW files into the cloud? The files was importet from Canon EOS via camera adapter to the iPad. The Files was stored in the folder importet. But the files does not sync with photostream.

    How to sent importet RAW files into the cloud? The files was importet from Canon EOS via camera adapter to the iPad. The Files was stored in the folder importet. But the files does not sync with photostream.

    Welcome to the Apple community.
    Only photos taken on the iOS device and after photo stream was enabled will be added to photo stream.

  • How to load local html-file into webBrowser tool? [SDK 6.5]

    The webbroser tool lets you load an external html by inputting the adress in its "Url"-property.
    But how do you load a local html-file that is added to your project? Lets say the path is: Folder1/Subfolder1/Webpage1.html. What would I put in the Url-property to make this work?
    While on this subject, what is the support for css and javascript when using locally loaded webpages in the webbrowser?

    Thanks for the answer Malleswar, but I have now played around with all variations of that code-line that I can think of, but still I can not locate the html-file that is located within the project. Since Im planning to distribute the html-files with the executable (as one file) it should read it directly from wherever the application is installed.
    The html-file is included within the project. Solution Explorer -> Solution 'myProject' -> myProject -> Webpage1.html
    Which is (as usual) also where the Form1.cs (which contains the webBrowser-component) is located.
    Any ideas of how the Uri should be constructed in this case?
    Thanks,
    Daniel

  • How to convert a HTML files into a text file using Java

    Hi guys...!
    I was wondering if there is a way to convert a HTML file into a text file using java programing language. Likewise I would also like to know if there is a way to convert any type of file (excel, power point, and word) into text using java.
    By the way, I really appreciated the help that you guys gave me on my previous topic on how to extract tests from a pdf file.
    Thank you....

    HTML files are already text files. What do you mean you want to convert them?
    I think if you search the web, you can find things for converting those MS Office files to text (or extracting text from them, as I assume you mean).

  • How to import a XML file into the document?

    Hai,
    i had created a table using xml file....
    Now i want to import that xml file tabel into the document...
    Can any one tell me how to import the xml file into the document?
    thanks
    senthil

    Hai...
    this is senthil...
    i'm beginner for creating adobe indesign plugins..
    i want to import a html file in the document...
    i want to create a table by using html tags and
    that table will be imported into the document..
    How shall i do it?
    can any one plzz explain me?

  • How to import an .csv file into the database?

    and can we code the program in JSP to import the.csv file into the database.

    It is better to use Java class to read the CSV file and store the contents in the database.
    You can use JSP to upload the CSV file to the server if you want, but don't use it to perform database operations.
    JSPs are good for displaying information on the front-end, and for displaying HTML forms, there are other technologies more suitable for the middle layer, back end and the database layer.
    So break you application into
    1) Front end - JSPs to display input html forms and to display data retrieved from the database.
    2) Middle layer - Servlets and JavaBeans to interact with JSPs. The code that reads the CSV file to parse it's contents should be a Java Class in the middle layer. It makes use of Java File I/O
    3) Database layer - Connects to the database using JDBC (Java Database Connectivity), and then writes to the database with SQL insert statements.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Keeping the above concepts in mind, first build a simple JSP and get it to work,
    then research on Google , for Java File I/O , discover how to read a file,
    Then search on how to readh a CSV file using Java.
    After researching you should be able to read the CSV file line by line and store each line inside a Collection.
    Then research on Google, on how to write to the database using JDBC
    Write a simple program that inserts something to a dummy table in the database.
    Then, read the data stored in the Collection, and write insert statements for each records in the collection.

  • After creating a new user account, how do I move my files into the new user?

    I have an issue where my 'Desktop/Screensaver' prefs seem to be corrupt somehow. When I click on that icon in System Preferences, it stalls and I get the spinning ball, thus resulting in a force quit. After reading a Mac Format magazine where someone wrote in with a similar issue, they said to trash various prefs (did that and made no difference) and if that didn't work, try creating a New User account (therefore creating brand new system prefs) and move your stuff over.
    Well, I've created the New User account, but I can't figure out how to move/copy my stuff into the user folders. After copying and attempting to move stuff in, I see folders with a red circle with a white line through it (like a 'no entry' sign).
    Any clue as to how this can be done? All I'm trying to do is to reinstate the system prefs so they are not corrupt anymore on my log-in.

    No. Not the main Library folder. Make absolutely sure you are in the Home Library folder and not the main Library folder.
    Your Home Library folder is hidden in Lion. To get to it, in the Finder menu, select GO and hold the option key down. Select Library in the submenu. The Finder window will open in your Home Library. This is where your user prefs are stored.
    Once there, you will see the Preferences folder. Open it up, select all items within it and move them to the trash. You will need to restart in order for the new Finder preferences to be recreated.
    Once you restart, then you will be back to the default preferences to the system and all applications. And yes, it will affect all settings including your Dock, just as logging into a new user. You will have to reset everything there also.
    If you wish to do a selective method, instead of deleting all preferences, try deleting the one associated with your problem. Screen saver problems should be affected by the system preferences, so try deleting this:
    com.apple.systempreferences.plist
    com.apple.systempreferences.plist.lockfile
    Note that when you delete system file preferences, a restart will be required. For applications, just quit the application before trashing preference files.

  • How to read an excel file into the datatable in sdk code( AddonApplication)

    Hi Experts,
    Please let me know the code ,how to write an excel file to the datatable and based on the datatable it should write to the database table.
    help would be appreciated...
    Regards,
    Vijay Kumar
    Edited by: Haroon Rasheed on Oct 29, 2011 10:40 PM

    Hi,
    You may check: Read Excel File by Sheet then put it in Matrix
    Thanks,
    Gordon

  • How to combine 3 HTML files into 1 HTML file?

    I'm designing a few layouts for my website recently, and have faced several problem. One of those is regarding "HTML coding", I usually upload files from Photoshop to Dreamweaver and it will automatically help me to generate the HTML code. I wanted to upload my own HTML layout design for my personal blogspot. But I realise that blogspot only allow 1 HTML code for the entire website design and when I did my web design in Dreamweaver (my website consists of HOME, ABOUT, CONTACT pages), it has a total of 3 HTML code for different pages and I couldn't upload it to my blogspot. So I would like to ask how can I actually do to combine all 3 HTML codes into 1 HTML code. Thank you.

    Hi Nancy, I would like to ask you if I'm using Illustrator CS6 instead of Photoshop? After I slice the vector file, I save as web devices > PNG file. But I realise that Ai and Psd do not work as the same, in Ai, it could not save as HTML. So what should I do after slicing images in Ai? :-D
    Another issue I'm facing is that do I have to create <div class> and <div box> to combine all the HTML files together into 1 and upload to blogspot? (1 long HTML that consists of HOME, ABOUT, CONTACT pages). Thank you

  • How do I place a file into the body of the email rather than as an attachment?

    I sometimes want to include a file, such as a "card" into the body of an email rather than as an attachment so that it appears immediately upon opening the email. I did this successfully at Christmas, but cannot remember how to do so now.

    The email specification doesn't allow that. PDF files, as for any content other than text or HTML, has to be sent as a link or an attachment.

  • How to load a XML file into the database

    Hi,
    I've always only loaded data into the database by using SQL-Loader and the data format was Excel or ASCII
    Now I have to load a XML.
    How can I do?
    The company where I work has Oracle vers. 8i (don't laugh, please)
    Thanks in advance!

    Hi,
    Tough job especially if the XML data is complex. The have been some similar question in the forum:
    Using SQL Loader to load an XML File -- use 1 field's data for many records
    SQL Loader to upload XML file
    Hope they help.
    Regards,
    Sujoy

Maybe you are looking for

  • Calculator square root event listener

    I am trying to write a calculator using JButtons added onto Jpanels. Getting numbers to add , divide, multilpy etc. is simple enough, but i need to write an event handler for a button which calculates the square root of a given number. This is easy e

  • Container managed bean persistence queries

    Hi, I want to know where the container generated java sources and classes for the container managed beans will be sotred as i want to look out the sql queries that is not inserting and updating the values into the tables. As well i want to refer how

  • EOIO should be enabled for Inbound IDocs to SAP

    Hi All, My Interface requirement: i want to send my IDoC's to SAP ECC from SAP PI using IDoc Adapter in EOIO manner. so i have followed the below link. http://help.sap.com/saphelp_nwpi71/helpdata/EN/96/791c42375d5033e10000000a155106/frameset.htm 1)I

  • RE: Adobe Photoshop Elements 10 re - installation issues

    I have a full version of Adobe Photoshop Elements 10 for Windows. I am presently having issues with reinstalling PSE 10. I have valiantly tried to get PSE 10 to reinstall and it will NOT reinstall for me. I am really frustrated at this juncture. Is t

  • OTN Mobile Web Serivces.

    After I successfully used the Live OTN MOBILE WEB SERVICE to send sms to any mobile phone. at the second day while I try to send, I got the following error OTN Authentication Failure I urgent need your help.