Displaying an html page from a byte array

I'm trying to display an html page that i receive from a byte[ ] but the navigator asks me to download it instead of displaying it.

exactly a better option here would be display that HTML content using a dedicated servlet/jsp.
checkout below example code snippet hope that might help
public void doPost(request,response)throws ServletException,IOException{
  //fetch HTML bytes.
  Byte buffer[] = Delegate.getBufferData(); 
  ByteArrayInputStream in = new ByteArrayInputStream(buffer);
  int contentSize = in.available();
  response.setContentType("text/html");
  response.setContentLength(contentSize);
  BufferedOutputStream out = null;
   try{
        out = new BufferedOutputStream(response.getOutputStream());
        while( contentSize-- >  0 )
            out.write(in.read());
         out.flush();
   }catch(Exception exp){
         exp.printStackTrace();
          throw new Exception(exp.getMessage());
   }finally{
          try{
                if(out != null)
                   out.close();
                if(in != null)
                    in.close();
          }catch(Exception ep){
                          ep.printStackTrace();
                          throw new Exception(ep.getMessage());
          }finally{
                out = null;
                in = null;
}and respectively call the servlet.
Hope this might help :)
REGARDS,
RaHuL

Similar Messages

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • How to use JEditorPanel to display an HTML page from a String?

    Hi,
    I need to store a report in HTML format which is store in String and when I use JEditorPane.setText to insert the string and JeditorPane refused to display and content or just the String "<HTML> <HEAD>..." in plain text. SHould I use other method to do the job?
    I also need to print it out from the Jeditorpane too. What do u suggest?
    Thanks.

    I got the HTML stuff working just yesterday. I don't know if there is a "more correct" solution:
            String message = "<head></head><body>Blagh blagh</body>";
            JEditorPane textpane = new JEditorPane();
            HTMLEditorKit kit = new HTMLEditorKit();
            textpane.setEditorKit(kit);
            textpane.setText(message);If you're not having luck then it may be because your HTML is wrong. I know that if I had poorly constructed HTML then it did originally display as plaintext.

  • Oppening a html page from a swing applincation

    How to display a html page from a user interface developed in swing(specially via a JButton.
    please help me!!!!!!!!!

    look at
    developer.java.sun.com/developer/Books/ gui/swing2/swing2_chap20.pdf
    source :
    http://www.manning.com/sbe/files/swing2e/Chapter20.zip
    It's an simple HTML editor

  • Displaying HTML page from JFrame

    Hi ,
    I have a JFrame GUI with menus and menu items. After Clicking on the Help Menu Item, I want to display a HTML page. Does anyone know of a function to display an HTML page?

    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    // This class is used in the Image Tool class when the help menu item is selected
    public class HelpMenu extends JInternalFrame implements HyperlinkListener{
    // A new JEditorPane to display the help html file in.     
    private JEditorPane jep;
         public HelpMenu () {
              super("Help Menu",
                        true, //resizable
                        true,     //closable
                        true,     //maximizable
                        true);     //iconifiable
              // Set the size and location of the frame
              setSize(500,500);
              setLocation(20,20);
              // create the JeditorPane
              jep = new JEditorPane( );
         jep.setEditable(false);
              // Make jep a scrollable pane
              JScrollPane jsp = new JScrollPane(jep);
         getContentPane( ).add(jsp, BorderLayout.CENTER);
              // Add a listener to listen for hyperlinks within the document
         jep.addHyperlinkListener(this);
         try {
         String HelpFile = "file:C:/Documents and Settings/Patrick/Desktop/Help.html";
         jep.setPage(HelpFile);
              // If the file can be loaded display the frame
              setVisible(true);
         catch(Exception e) {
              // The file could not be loaded.
              System.out.println(
                   "Could not open help page! Has it been deleted from: C:/Documents and Settings/Patrick/Desktop/");
              // If the file can not be loaded display an error message
              JFrame f = new JFrame();
         JOptionPane.showMessageDialog(f, "Could not open help page! Has it been deleted from: C:/Documents and Settings/Patrick/Desktop/",
                   "Help Menu", JOptionPane.WARNING_MESSAGE);
              // If the file cannot be loaded do not display a frame
              setVisible(false);
    public void hyperlinkUpdate(HyperlinkEvent he) {
    HyperlinkEvent.EventType type = he.getEventType( );
         if (type == HyperlinkEvent.EventType.ACTIVATED) {
    try {
    // set the page to show the selected section of the file
    jep.setPage(he.getURL( ));
    catch (FileNotFoundException e) {
    catch (Exception e) {
    }     

  • How to extract image from oracle database and display at html page

    Could you help me how to make the image to display. i manage to extract the data but the data is in Blob so i need to convert it so make it display at html page.

    Thanks for ur reply Mr.Rajasekhar
    I tried as u said,
    i tried without converting to sql date ,but still i din't get any results
    java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
              String query1="select MTName,Date,MTLineCount from linecountdetails where mtname='"+MTName+"'  and Date >='"+fromDate+"' and Date <='"+tillDate+"' " ;
            System.out.println(query1);
    //From main method
    databaseConnection("prasu","1/12/2005","31/12/2005");I got the output as
    ---------- java ----------
    select MTName,Date,MTLineCount from linecountdetails where mtname='prasu'  and Date >='Thu Dec 01 00:00:00 GMT+05:30 2005' and Date <='Sat Dec 31 00:00:00 GMT+05:30 2005'
    java.lang.NullPointerException
    null
    null
    java.lang.NullPointerException
    Output completed (4 sec consumed) - Normal TerminationThanks
    Prasanna.B

  • IPhone SDK - Display HTML page from WITHIN package

    Hi all,
    As part of my iPhone app, I want to display an HTML page.
    Now, I've got a browser component working just fine, and have no problem displaying anything on the web, but i don't know how to reference an html page that is WITHIN my application package.
    I'd much rather do it this way, so that my app can be used offline.
    I'm sure its a simple thing to do... anyone know what i need to do here to make this work?

    NSString *welcomeFile = [bundle pathForResource:@"welcome" ofType:@"html" inDirectory:@"files"];
    NSString *content = [NSString stringWithContentsOfURL:[NSURL fileURLWithPath:welcomeFile]];
    NSString *baseUrl = [bundle pathForResource:@"files" ofType:nil];
    [webView loadHTMLString:content baseURL:[NSURL fileURLWithPath:baseUrl]];

  • How to Create HTML page from portal

    Hi
    I have a requirement to create html pages from portal.
    There will be an author who can choose document type as HTML
    and then he will write html codes on saving it should be saved as HTML doc in UCM.
    and publisher should be able to display it on portal(may be using content presenter).
    please help me in this. I know there is rich text editor task flow which can save a doc as doc file.
    and in spaces we have option of creating HTLM file but i don't know how to do it for my portal.
    Thanks

    A better way would be to create the page using approach in this blog:
    https://blogs.oracle.com/ATEAM_WEBCENTER/entry/content_presenter_cmis_complete
    That way the page can be edited inline and the html author need not upload html to ucm everytime.

  • How to display the HTML pages in RRC/RQM dashboard using OpenSocial gadget

    Hi,
    I have a requirement as below:
    1. I have couple of HTML pages which are hosted in the sharepoint site and I would like to display the HTML pages
    2. I would like to have an OpenSocial gadget in the RRC/RQM dashboard that will display the HTML pages  which are hosted in my sharepoint site.
    Could you please suggest the best approach to create an OpenSocial gadget in the IBM's RRC/RQM dashboard whcih will display html contents of another URL ?
    Thanks.
    Knowledge is power.

    Hi Manoj,
    As I understand, you would like to display SharePoint page in another platform.
    Since the you are involving third party platform, you might still need to contact their support engineer about how to render other pages.
    From SharePoint side, by default, SharePoint won't let end user to display site page to other platform, you could add "<WebPartPages:AllowFraming runat="server"/>" in master page or single page layout. So that SharePoint ASP.Net
    page could be displayed on other platform.
    Here I'm talking about ASP.Net page, since HTML page in SharePoint cannot be displayed in browser as I tested, it will be downloaded directly. So I'd suggest you use ASP.Net page as workaround.
    https://social.msdn.microsoft.com/Forums/office/en-US/c8755a6b-f33a-43ed-97d9-8f03c336aa1d/how-to-display-sharepoint-url-in-iframe-in-aspnet-page?forum=sharepointdevelopment
    Regards,
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected] .
    Rebecca Tu
    TechNet Community Support

  • Access HTML Pages from Forte Applications

    We are currently looking at how to redevelop our online help facility for a
    Forte application. We are investigating the use of HTML pages.
    Has anyone written a Forte application that opens particular HTML pages? If so,
    how was it done?
    Regards,
    Steve Isaac
    Senior Consultant, Information Services Group
    Hydro Electric Corporation of Tasmania
    4 Elizabeth St, Hobart, Australia, 7000
    Phone : +61 03 6230 5161
    e-mail: [email protected]

    We have created the idea of an OnLineAssistant that uses HTML pages to drive
    help in a Wizard-like fashion.
    We use an embedded ActiveX browser control in a Forte window to display the
    HTML pages. The pages are launched by passing the application, window, and
    widget name to the OnLineAssistant window, which uses the information to load
    the correct page.
    For example: an application screen for entering customer name and address
    passes it's information to the on-line assistant, which links and displays the
    page associated with that particular step of a task wizard defined for that
    widget. The ActiveX control then allows the user to link into any of the
    other pages associated through standard HTML.
    This context-sensitive mechanism is also used to launch on-line help (without
    the task orientation) at the user's request.
    One of the benefits of this approach is that we can put the message passing
    into a generic framework ancestor without making any application code changes,
    and the OnLineAssistant HTML pages can then be created by non-programmers and
    deployed independently from the application, and HTML can do most of the
    navigation work.
    -DFR

  • Open HTML page from the stage

    How can I open a HTML page by pressing a button on the stage?
    I've created a rollover button and I'm trying to make it open
    an existing html page from the local disk (not an internet URL).
    But I can't make it open with Lingo or behaviour.
    Please help.
    Thanks a lot.
    Gideon.

    goToNetPage "
    http://somewhere.html" is the
    typical form for a page on
    the web, director must use the address format the system's
    browser uses
    for local files, this is somewhat platform dependant, a
    practical
    aproach is to open the file in question from within your
    browser then
    copy and paste the displayed address into your lingo code.
    Some report the goToNetPage counterpart provided by the
    buddyAPI xtra
    works more reliably, the xtra can be used for free if limited
    to a
    couple of functions.
    An alternate approach buddyAPI can use is to have the browser
    directly
    access the html file as if it were double clicked in the file
    manager
    using the same form commonly used to open PDF files with
    acrobat.
    (sorry I don't have example code handy)

  • Creating a HTML page from the J2ME application

    Hi,
    I am developingan application in J2ME. Can anyone of you out there, help me whether there is any way I can generate a HTML page from the application.
    I have the data but I don't know ho to create a HTML page from a J2ME application.
    Any document or any code will prove handy.
    Thanking in anticipation.
    Ashish

    When you say that "you have the data" you mean that you have HTML code data(<html><body>Hello World</body></html>)? If yes you should create an algorithm that "read" html tag and display text in the appropriate layout/font/size/color...
    A solution could be simplify your HTML code (server side), so you can easly "decode" and display text.
    Giovanni
    Italy

  • Report HTML page from XSL

    Hi All,
    I need help with generation HTML page from
    such XML by using XSL transformation.
    XML is generated from db table.
    <ITEM level=0 name="Page row 1" type="PR"/>
    <ITEM level=1 name="Page row 2" type="PR"/>
    <ITEM level=2 name="Table 1" type="T">
         <Captions>
              <Name>Caption 1</Name>
              <Name>Caption 2</Name>
              <Name>Caption 3</Name>
              <Name>Caption 4</Name>
         </Captions>
    </ITEM>
    <ITEM level=3 name="Table row 1" type="TR">
         <Values>
              <Value>Row 1 value 1</Value>
              <Value>Row 1 value 2</Value>
              <Value>Row 1 value 3</Value>
              <Value>Row 1 value 4</Value>
         </Values>
    </ITEM>
    <ITEM level=3 name="Table row 2" type="TR">
         <Values>
              <Value>Row 2 value 1</Value>
              <Value>Row 2 value 2</Value>
              <Value>Row 2 value 3</Value>
              <Value>Row 2 value 4</Value>
         </Values>
    </ITEM>
    <ITEM level=3 name="Table row 3" type="TR">
         <Values>
              <Value>Row 3 value 1</Value>
              <Value>Row 3 value 2</Value>
              <Value>Row 3 value 3</Value>
              <Value>Row 3 value 4</Value>
         </Values>
    </ITEM>
    <ITEM level=0 name="Page row 3" type="PR"/>
    <ITEM level=1 name="Table 2" type="T">
         <Captions>
              <Name>Caption 1</Name>
              <Name>Caption 2</Name>
         </Captions>
    </ITEM>
    <ITEM level=2 name="Table row 4" type="TR">
         <Values>
              <Value>Row 1 value 1</Value>
              <Value>Row 1 value 2</Value>
         </Values>
    </ITEM>
    HTML should looks like:
    Page row 1
         Page row 2
              |Caption 1 |Caption 2 |Caption 3 |Caption 4 |
              | Row 1 value 1|Row 1 value 1|Row 1 value 1|Row 1 value 1|               
              | Row 2 value 1|Row 2 value 1|Row 2 value 1|Row 2 value 1|                         
              | Row 3 value 1|Row 3 value 1|Row 3 value 1|Row 3 value 1|               
              | Row 4 value 1|Row 4 value 1|Row 4 value 1|Row 4 value 1|               
    Page row 3
         |Caption 1 |Caption 2 |
         | Row 1 value 1|Row 1 value 1|
         | Row 2 value 1|Row 2 value 1|
    There can be many levels but always table item is leaf,
    Thanks in advance,
    Regards Peter

    Hi
    You are probably better posting in the flash forum, as without seeing the code, (and if it is not standard flash html publish) they can probably better advise on a solution.
    PZ

  • Referencing static html pages from jsps...

              Hi,
              This is probably a very simple thing to solve, but I'm having problems with referencing
              html pages from jsps under Weblogic.
              I get Error 404 - not found, whenever I try something like this in a JSP...
              <frame name="title" src="title.html" scrolling=no>
              The title.html file has definitely been copied into my ear file, and yet it isn't
              found. I can solve the problem by turning title.html into a jsp and registering
              it in web.xml. But this seems like serious overkill with static content!!
              Am I missing something really simple here?
              

              I've worked it out - directory mistake...
              Thanks,
              Chris
              "Matt Krevs" <[email protected]> wrote:
              >it sounds like a relative pathing problem
              >
              >is title.html reachable if you enter its address in the browser?
              >
              >is title.html in the same directory as your jsp?
              >
              >perhaps you could post your web.xml file?
              >
              >"Chris Sceats" <[email protected]> wrote in message
              >news:3d9c41b5$[email protected]..
              >>
              >> Hi,
              >>
              >> This is probably a very simple thing to solve, but I'm having problems
              >with referencing
              >> html pages from jsps under Weblogic.
              >> I get Error 404 - not found, whenever I try something like this in
              >a
              >JSP...
              >>
              >> <frame name="title" src="title.html" scrolling=no>
              >>
              >> The title.html file has definitely been copied into my ear file, and
              >yet
              >it isn't
              >> found. I can solve the problem by turning title.html into a jsp and
              >registering
              >> it in web.xml. But this seems like serious overkill with static content!!
              >>
              >> Am I missing something really simple here?
              >
              >
              

  • May by anyway view Local Network files[e-book] or videos or html pages, from the main PC

    In ipad 3 upgraded to 4 ios, may by anyway view Local Network files[e-book] or videos or html pages, from the main PC if, this main has local host[php/mysql] or, from the local network itself: eg //user/downloads/pdf/ebook1.pdf?

    In ipad 3 upgraded to 4 ios, may by anyway view Local Network files[e-book] or videos or html pages, from the main PC if, this main has local host[php/mysql] or, from the local network itself: eg //user/downloads/pdf/ebook1.pdf?

Maybe you are looking for