Displaying a jpg on the browser using a simple http server.....

Hi
I've written a simple server which responds by sending a jpg file .
BROWSER ---request---> SERVER ( reads a jpg file, converts to byte[] and writes to browser )
^
|
|
<----response ----------
So I connect from the browser and the server sends a jpg and I'd to display that. Everything is thru sockets. There is no webserver as such.
The problem is, I'm getting the text fine, but instead of the picture, I get lots of characters...probably the browser is unable to interpret the jpg . How to I display the jpg ? Do I have to convert the characters in the server code before sending it ?
Anything to do with Base64 encoding ??
Thanks !!

All answers to this question including mine disappeared ??????
In order to serve an image or any other type of data over the HTTP protocol you have to supply the correct HTTP response header with the data.
The stream of bytes written to the client should be structured like this:
A status code followed by several lines of key/value pairs with header information, a blank line and finally the bytes of the image.
All lines in the header should end with \r\n no matter what OS the server is running.
HTTP/1.1 200 OK
Date: Wed, 07 Nov 2001 18:37:47 GMT
Server: MyServer/0.1
Content-Type: image/jpeg
Content-Length: 4321The Content-Length field must have the length of the image data in bytes. The Content-Type field must be the correct mime type for the image data.
Read RFC 2068 if you want or need more information.

Similar Messages

  • Maximum number of records displayed on the browser using Query Designer.

    When you display a query on the web using Query Designer is there a maximum limit of how many records (rows) it can display? For example, can it handle 25 million records?
    Thanks.

    Hi Sebastian,
    I still find such a requirement weird as one cannot definitely go thru' so much of data at a time - it would thus always make sense to perhaps filter on some criteria which would make analysis & perhaps even download much faster. The limit as I understand is approx 750,000 data cells. Maybe the below link & SAP notes can help validate
    Limitation in No. Of data cells displayed in BEx Analyzer
    SAP Notes :-
    Note 1040454 - Front-end memory requirement of the BEx Analyzer
    Note 1030279 - Reports with very large result sets/BI Java
    Note 1411545 - BExAnalyzer: safety belt for large resultsets
    --Priya

  • How to display "Image" object in the browser?

    can anyone please tell me how can i display "Image" object in the browser?
    I have an image object that i retrieved from AS400 BLOB object by using toolbox.jar (for as400 access for java including all necessary classes like jdbc driver, security etc.).
    i want to display this object in the browser so i will be able to web-enable my BLOB objects stored on as400.thx...

    In your HTML:
    <img src="ImageServlet">
    In ImageServlet:
    Make calls to DB to get your image as byte array and store it in:
    byte[] buffer = new byte[imageSize];
    ServletOutputStream out = response.getOutputStream();
    for(int i = 0; i < imageSize; i++)
    out.write(buffer, i, 1);
    out.close();

  • Uploading the file to server from the browser using JSP

    I have facing difficulty while uploading the file from the browser using user interface to the server or to the database. As previousy i was working in coldfusion, i find it very easy there with cffile command, but i am confused how to do that in JSP
    please reply soon, as i am stuck in my project because of that
    Sarosh

    Check out http://www.jspsmart.com , They have a nice free upload api that can be used w/ JSPs or Servlets. I hear O'Reilly has a nice one too. May as well use someone elses if they've done it already.

  • How to upload the image and diplay the image in the browser using jsp

    How to upload the image and diplay the image in the browser using jsp
    thanks
    shan

    i'll suggest looking for sample code or tutorial with a relevant query in google, which as far more time than us to answer this type of reccurent question

  • Can we select a particular area in the browser using Flex?

    Hi All,
    Is it possible to select particular area of the flex
    application in the browser using Flex and generate that area into a
    image when an button is clicked?
    Please help me.
    Thanks in advance

    Yes, you should google Flex screenshot bitmap, there are a
    number of examples. As far as 'selecting' one of the examples may
    show this, but you can just use a Canvas or similar for the box
    drawing (set background transparent, and just use the borders, and
    resize the canvas on mouse events). Otherwise you can do the
    Graphics sorite drawing by hand or use something like Degrafa for
    fancier, or look up quasimodo marching ants for an animated
    selection technique.

  • Opening a Document (.doc, .xls, .pdf) in the browser using an action

    Hello
    I´m using JavaScript to open a document in the browser using the property Onclick from Command Button: onclick="#{backing_archivos.rutaArchivo}"
    and in the backing_archivos.rutaArchivo I have the String window.open("file://c://tmp/document.pdf", "title page", "top=100, left=100")
    but the browser doesn't open anything.
    What can I do?
    Thank.

    You can do an external file by using a stream and and the response object. I have this in a backing bean, and it gets called with a command button.
    public String runQCReport_action()
    BindingContainer bindings = getBindings();
    OperationBinding operationBinding = bindings.getOperationBinding("PromotionRequestQCReport");
    Object result = operationBinding.execute();
    FileInputStream bis = null;
    ServletOutputStream bos = null;
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = (HttpServletResponse)context.getExternalContext().getResponse();
    response.setContentType("application/pdf");
    response.setHeader("Content-disposition","inline=filename=file.pdf");
    try {
    File fileName = new File("applications/reports/output/PromotionRequestQCReport.pdf");
    bis = new FileInputStream(fileName.getAbsolutePath());
    bos = response.getOutputStream();
    byte[] buff = new byte[2048];
    int bytesRead;
    while (-1 !=(bytesRead = bis.read(buff,0,buff.length)))
    bos.write(buff,0,bytesRead);
    //response.getOutputStream().write(yourdata[]);
    response.getOutputStream().flush();
    response.getOutputStream().close();
    context.responseComplete();
    catch (IOException e) {
    e.printStackTrace();
    return null;
    }

  • Send a file that resides above the virtual directory to the browser using ASP.

    How do you send a file that resides above the virtual
    directory to the browser using ASP.
    this doesn't work:
    <% Response.Redirect(Server.Mappath("..\..\..\files\"
    & rsgetefile("filename"))) %>

    Basically you can't send a person to the location as that
    would totally
    defeat the purpose of placing files above the virtual root.
    You can stream a
    file from a page on the site if you use the physical location
    on the server
    to call it.
    Paul Whitham
    Certified Dreamweaver MX2004 Professional
    Adobe Community Expert - Dreamweaver
    Valleybiz Internet Design
    www.valleybiz.net
    "lovewebdev" <[email protected]> wrote in
    message
    news:ec2paf$9ht$[email protected]..
    > How do you send a file that resides above the virtual
    directory to the
    > browser using ASP.
    >
    > this doesn't work:
    > <% Response.Redirect(Server.Mappath("..\..\..\files\"
    > rsgetefile("filename"))) %>
    >

  • How to change the browser used for Google search from context menu of selected text?

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

    How to change the browser used for Google search from context menu of selected text?
    It uses Safari. But I want to use Chrome (it's my default browser).

  • How can we get the source of the page which is loaded on the browser using

    Dear Sir,
    How can we get the source of the page which is loaded on the browser using javascript
    What is the exact path to get the source object in JS?
    thanks & regards,
    Sudheesh - INDIA

    um... the document object?

  • Hello! I am writing to inform you that about that you have a problem displaying your website in the browser.

    Hello! I am writing to inform you that about that you have a problem displaying your website in the browser.
    In Yandex browser. I decided to tell you, because the site is not displayed correctly. As in the screenshot.

    apart from the fact there's no way I could have answered your question confidently, I was also not able to supply my non-answer within your very tight time constraints.
    what happened? how'd you get on?

  • The WinRM client received an HTTP server error status (500)

    Hi All,
    I have installed the Exchange 2010 Management Tools and a few roles on our DC (Windows Server 2008 R2) but i cannot even connect to it to configure anything.
    If i use the management tools GUI i get an error message saying:
    "Connecting to remote server failied with the following error message: The WinRM client received an HTTP server error status (500), but the remove service did not include any other informaition about the cause of the failure. For more information, see the about_Remote_Troubleshooting Help topic. It was running the command 'Discover-ExchangeServer -UseWIA $true -SuppressError $true'."
    Using the Exchange Management Shell is get a similar error:
    "Connecting to remote server failied with the following error message: The WinRM client received an HTTP server error status (500), but the remove service did not include any other informaition about the cause of the failure. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportException
    + FullyQualifiedErrorId: PSSessionOpenFailed"
    This comes up 3 times and then said it failed to connect and to enter the Server FQDN i want to connect to.
    I have seen other posts where they have said to disable anonymous access for PowerShell in IIS which i have done and to also run the set-user yourusername -remotepowershellenabled:$true which i cannot run because i cannot even connect into it via PowerShell.
    Tried to see if there was a way to reinstall the management tools because i have a feeling they didnt install properly but cant find a way to do that.
    Tried to uninstall everything but i cannot because it says there are already mailboxes created (presume some default ones) but i cannot connect to remove them to uninstall.
    I seem to have reached a wall and cannot see how to proceed.
    Please help. Thanks.

    Have you tried loading EMS via Admin Tools > Windows Powershell Modules? Amazingly, that will probably work fine for you.
    Assuming that loads, or that you can run EMS on another machine:
    Check Powershell directory in IIS on the problem server. Make sure SSL is not required. Allow only Anonymous access - no basic/IWA auth etc.
    If you can get into Windows Powershell Modules, run the set-user command suggested above from there.
    Remove-powershellvirtualdirectory, and then New-powershellvirtualdirectory (either remotely or using Windows Powershell Modules.
    Re-check SSL/authentication once this is done.
    -Max
    Hi Max,
    Tried loading EMS via Admin Tools > Windows Powershell Modules but didnt work. Got the following error:
    Import-Module : There were errors in loading the format data file:
    Microsoft.Exchange.Management.PowerShell.Setup, C:\Program Files\Microsoft\Exchange Server\V14\bin\Exchange.format.ps1x
    ml : File skipped because it was already present from "Microsoft.Exchange.Management.PowerShell.E2010".
    At line:24 char:34
    +                     Import-Module <<<<  $_.Name -ErrorAction SilentlyContinue
        + CategoryInfo          : InvalidOperation: (:) [Import-Module], RuntimeException
        + FullyQualifiedErrorId : FormatXmlUpateException,Microsoft.PowerShell.Commands.ImportModuleCommand
    I think it is a problem with the PowerShell IIS VirtualDirectory because when i browse any other virtual directory i get a response of some sort but when i browse the PowerShell virtual directory i get the same 500 error message.
    This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.
    Now i think i have made things worse. I was looking at the remove and new point you made an accidently deleted the whole PowerShell virtual directory in IIS using the IIS GUI. I didnt use the Remove-powershellvirtualdirectory command. Now i dont know how to get it back :(
    When i try to run New-powershellvirtualdirectory and specify to call it PowerShell it says it is already
    New-PowerShellVirtualDirectory : The virtual directory 'PowerShell' already exists under 'DC01.mainserver/Default Web S
    ite'.
    Parameter name: VirtualDirectoryName
    At line:1 char:31
    + New-PowerShellVirtualDirectory <<<<
        + CategoryInfo          : InvalidArgument: (DC01\PowerShell (Default Web Site):ADObjectId) [New-PowerShellVirtualD
       irectory], ArgumentException
        + FullyQualifiedErrorId : 7833EE63,Microsoft.Exchange.Management.SystemConfigurationTasks.NewPowerShellVirtualDire
       ctory
    I have tried to use the remove command but it doesnt find it no matter what i put in the identify parameter. It should be "Default Web Site" right?
    Anyways, i have created a new PowerShell virtual directory called ExchPowerShell (still would like to find a way have it called PowerShell) and removed SSL and enabled only Anonymous access. Now get a different error message:
    VERBOSE: Connecting to DC01.mainserver
    [dc01.mainserver] Connecting to remote server failed with the following error message : The WinRM client sent a request
     to an HTTP server and got a response saying the requested HTTP URL was not available. This is usually returned by a HT
    TP server that does not support the WS-Management protocol. For more information, see the about_Remote_Troubleshooting
    Help topic.
        + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
       eption
        + FullyQualifiedErrorId : PSSessionOpenFailed
    Did a search and i think this is because i now had a different PowerShell virtual directory so if i try to connect and specify the new virtual directory name i get the same error i was getting.
    Failed to connect to any Exchange Server in the current site.
    Please enter the Server FQDN where you want to connect: DC01.mainserver/ExchPowerShell
    VERBOSE: Connecting to DC01.mainserver/ExchPowerShell
    [dc01.mainserver] Connecting to remote server failed with the following error message : The WinRM client received an HT
    TP server error status (500), but the remote service did not include any other information about the cause of the failu
    re. For more information, see the about_Remote_Troubleshooting Help topic.
        + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
       eption
        + FullyQualifiedErrorId : PSSessionOpenFailed
    Thank for all you help so far.

  • Exchange 2010 Initialization failed: The WinRM client received an HTTP server error status 500

    Good morning,
    I have major problems with exchange 2010 this morning.
    First off, exchange stopped sending and receiving any emails- whether internal or external. We are running a server 2008 R2 domain and exchange 2010 is installed on a Server 2008 virtual machine.
    I tried simply rebooting the server and then tried logging on and getting into the Exchange Management Console. I receive the following error in the exchange management console:
    Initialization failed
    The following error occurred while attempting to connect to the specified Exchange server 'exchangesvr.chs.internal';
    The attempt to connect to
    http://exchangesvr.chs.internal/Powershell using "Kerberos" authentication failed: Connecting to remote server failed with the following error message: The WinRM client received an HTTP server error status (500), but the remote service did not include any
    other information about the cause of the failure. For more information, see the about_Remote_Troubleshooting Help topic.
    I followed the steps listed here:
    http://technet.microsoft.com/en-us/library/ff607221(EXCHG.80).aspx
    but everything appeared to be correct. I did not have to make any changes because everything was set as it should be according to that information.
    Any help would be much appreciated.
    Best regards
    Katrina

    Hi,
    I had the same problem, and I spent a weekend looking a solution, fortunally, I have it:
    Please follow this steps:
    Install WinRM IIS Extension, adding this feature from Server Manager.
    Change  IPv4 over IPv6 lookup preference, because the FQDN fails to find the server on TCP/IPv6. 
    To verify this, on Command Prompt please make this test: ping yourserver.yourdomain.domain. 
    Maybe you obtain TCP/IPV6 address response.
    Probably the Internet Information Services (IIS) Manager dont have the binding for IPv6, only for IPv4.
    To change IPv4 over IPv6 lookup group prefence, follow this steps:
    Please open regedit, locate the skubkey: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\
    On DisabledComponents subkey, double click, change de value for
    0x20 (or 4120 Hexadecimal). this value make  the Windows OS to prefer IPv4 over IPv6.
    Repeat the test, on command prompt:
    ipconfig /flushdns (Enter) to flush DNS cache.
    ping yourserver.yourdomain.domain.
    At this moment you obtain TCP/IPv4 address response.
    To check Exchange Managment Console operation, you must restart the server.
    Please restart the server.
              Best Regards,

  • Exchange 2010 Initialization failed (Initialization failed) The WinRM client received an HTTP server error status (502)

    i have Server 2008 r2
    exchange 2010 evrything was working fine but now when i try to open the Exchange management console i get this errore
    the follwing error ocurred when serching for on premises exchange server
    Connecting to remote server failed with the following error message:
    The WinRM client received an HTTP server error status 502,  from the remote ws-managment servic   For more information, see the about_Remote_Troubleshooting Help topic. It was running the command
    'Discover-ExchangeServer -UseWIA $true -SuppressError $true'.
    please help
    Mahmoud Hanefy

    Anything in the event logs?
    Any help from:
    http://msexchangeteam.com/archive/2010/02/04/453946.aspx
    Troubleshooting Exchange 2010 Management Tools startup issues

  • Excel Output is being displayed as HTML in the browser

    Hi All,
    I am using PeopleSoft XML Publisher 5.6.2 to generate an Excel report using RTF template. The report runs successfully.
    However, when I click the Output file link in the View Log page of process scheduler, the file is being displayed as a HTML page, though the extension of the file is .xls.
    Also when I try to save the file by using 'Save Taget as' option, the browser prompts me to save the file as 'mhtm' file and not 'xls' file.
    The following is an extract from the output file.
    <html>
    <!-- Generated by Oracle XML Publisher 5.6.2 -->
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>IM Top 10 Surplus &amp; Deficit Locations</title>
    After doing some research on Internet, I found the following blog post(dated back in 2008) to describe my situation and a workaround to the problem.
    http://peoplesofttipster.com/2008/04/16/xls-xmlp-output-opening-in-browser-not-excel/
    http://peoplesofttipster.com/2008/04/18/xls-xmlp-output-opens-in-browser-workaround/
    Workaround described in the above blog post is to update the charset to us-ascii replacing UTF-8. This seems to work. But with limited file processing capabilities of peoplecode, this workaround is not a simple solution.
    I also verified the mime-type mapping in the web.xml file in the webserver. Please find below the .xls mime-type mapping in the web.xml file.
    <mime-mapping> <extension> xls </extension> <mime-type> application/vnd.ms-excel</mime-type></mime-mapping>
    Question:
    1.How do I force the browser to open the excel output file using either Excel plugin or Excel Application instead of displaying it as HTML page?
    2.If not the above, how can I force the system to promt the user to save the file as Excel file instead of mhtml?
    Additional details :
    work enivronment
    PeopleSoft FSCM 8.9
    PeopleTools 8.48.17
    Oracle 10g
    Windows NT
    Any help would be greatly appreciated.
    Thanks & Regards,
    Vamsi Krishna

    Please try this by Open windows explorer, Click Tools -> Folder Options ->,Click on File Types and Select XLS from the list, Click Advanced, select "Open" and Make sure the “Browse in same window” is not selected.
    Hope this helps,
    Ramesh

Maybe you are looking for

  • Bank statement: problem to load variable length field

    we have many bank accounts with different banks, and we would like to use the bank reconciliation module to do bank reconciliation. we have problem in load the MT940 bank statement. All these banks are providing so called standard SWIFT940 format, wh

  • FrameMaker 10 Trial not installing Acrobat PDF Creator

    Hi, I am trying to install the Trial Edition of FrameMaker 10 on a Windows 7 PC, for evaluation. The installation of FM10 completes, however PDF Creator 10 is not installed even though I select for it to be done.  I would guess that there should be a

  • Unable to create editor ID com.m7.wide.eclipse.jstudio.DocEditor.jsp

    Posting this on behalf of abrahamkf from the jsp newsgroups. I am using eclips 3.1.2 and BEU free jsp editor. I have a eclipse project created by appfuse with the WEB-INF folder under 'web' directory, but my jsp pages are under the directory 'web/pag

  • Problem with nokia N81

    Hello  I have a nokia N81 and i recently installed whatsapp. While configuring it I was asked to enter the Username I entered my name on hitting the continue button the application closed automatically. Its annoying and I an unable to use the applica

  • Remote Shutdown Several Macs

    Here is my situation. I work in a computer lab containing both PC's and Macs, and at the end of the night, I want to be able to send a message to the users on the Macs stating that the computer will be shutting down in 20 minutes, and will automatica