Print images created on the fly by a servlet

Please, look at it... my tiff image doesn't print in my browser (IE6).
Could somone tell me why !????
// Method of a "Page" class
public void write (OutputStream out) {
            // Reading of the tiff file (this.tempFile is a valid File)
     PlanarImage image    = JAI.create("fileload", this.tempFile.getCanonicalPath ());
            /*   // Test : the writed file is a valid tiff file --> the reading is OK !
             *   File outFile = new File ("c:\\temp\\JLdsWeb\\Test.tif");
             *   RenderedOp op = JAI.create("filestore", image, outFile.getCanonicalPath (), "tiff");
     // Writing of the tiff file in the received OutputStream
            JAI.create("encode", image, out, this.FORMAT_NAME, null);
// my 1st JSP :page.jsp (to call the 2nd JSP witch have an other content type)
<%@page
contentType="text/html"
language="java"
errorPage="errorpage.jsp"
import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
%>
<html>
<head></head>
<body>
<IMG src=<%=request.getContextPath()%>image.jsp>
</body>
</html>
// my 2nd JSP
<%@page
language="java"
errorPage="errorpage.jsp"
import="com.damaris.ldsweb.*,com.damaris.data.*,com.damaris.page.*,java.util.*"
%>
<html>
<head>
<%
    // pageToPrint is an instance of the class "Page" (getContentType ( ) give the String "image/tiff")
    response.setContentType(pageToPrint.getContentType ( ));
%>
</head>
<body>
<%
    ServletOutputStream bOut = response.getOutputStream();
    pageToPrint.write (bOut);
%>
</body>
</html>

You can get the Servlet to write an image out by changing the content type of the response object to "image/jpeg" and write the bytes of the image out down a ServletOutputStream you create from the response object.
You must change the content type before you write anything to the response object. The servlet can only produce the image.
I did it once but I've lost my code and am now trying to recreate it (I changed it to having a server app do the image processing and writing it to a socket which the servlet read the bytes from and wrote them to the ServletOutputStream but now want the servlet to do the processing).

Similar Messages

  • Big Colour and detail changes between Original Nikon RAW files and the images created on the Preview page!

    Big Colour and detail changes between Original Nikon RAW files and the images created on the Preview page! Yes there are distinct visual changes when I preview my Nikon NEF RAW Files.Please note I do not use iPhoto at all.
    If you view it as a contact sheet straight from the original folder there are no alterations but the moment you double click and want to 'Preview' it, this new preview page introduces very noticeable distortions : lighter shading goes missing and colour goes darker e.g orange turns red and mid blue goes deep blue!  Alarmingly the little column on the left of the preview page showing the collection shows the original file colours and then after a few seconds show the new distorted image...you can see this visible change and it takes place after a few seconds once you double click! Also if you use Apple's 'Cover Flow' to preview, this function will replace your original RAW file with the new 'altered preview' image!
    I have raised this with Apple but they have yet to reply...has anyone ever experienced this? I have used my Mac book for 18months only noticed it about 5 days ago!
    I went to Apple store and we tried it in other laptops and Macs and it happened to all of them so we think this is a software issue and not down to the laptop.
    Any help is much appreciated!

    Big Colour and detail changes between Original Nikon RAW files and the images created on the Preview page! Yes there are distinct visual changes when I preview my Nikon NEF RAW Files.Please note I do not use iPhoto at all.
    If you view it as a contact sheet straight from the original folder there are no alterations but the moment you double click and want to 'Preview' it, this new preview page introduces very noticeable distortions : lighter shading goes missing and colour goes darker e.g orange turns red and mid blue goes deep blue!  Alarmingly the little column on the left of the preview page showing the collection shows the original file colours and then after a few seconds show the new distorted image...you can see this visible change and it takes place after a few seconds once you double click! Also if you use Apple's 'Cover Flow' to preview, this function will replace your original RAW file with the new 'altered preview' image!
    I have raised this with Apple but they have yet to reply...has anyone ever experienced this? I have used my Mac book for 18months only noticed it about 5 days ago!
    I went to Apple store and we tried it in other laptops and Macs and it happened to all of them so we think this is a software issue and not down to the laptop.
    Any help is much appreciated!

  • Please create "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]"?

    In Firefox 34, you have changed the search bar.
    The new style is perfect for those who always starts by typing in, letter for letter, the search term.
    People such as myself, we almost never type in the search term,
    but instead we mark a [word] in a text, right-click this marked [word], then select "Search [engine x] for [word]".
    Speaking for myself, I have now a total of 36 search engine providers, but I usually only use 7 of those.
    I use "Wikipedia (English)" most of the time..
    - but then I will switch to e.g. "AniDB" and use that one for 1 hour..
    - or switch to "Google" and use that one for 30 minutes..
    - or switch to "Wikipedia (Norwegian)" and use that one for 2 hours..
    - or switch to "Wiktionary (English)" and use that one for 15 minutes..
    ..and then I will switch back to "Wikipedia (English)" again.
    The way the search bar was in Firefox 33 and earlier, I could very easily switch the default search engine.
    Just one click to open the drop-down menu, then choose one.
    In Firefox 34, I have to choose "Tools" -> "Options", the "Search" tab..
    - before I can THEN click to open the drop-down menu.
    4 clicks instead of 1, that's like 400% more work..!
    Also, the fact that I have to go into "Options".. make this..
    ..I don't know how to put it, it's a kind of psychological barrier that I have to overcome each time.
    I mean, before Firefox 34, I went to the "Options" window like maybe 4 times each YEAR,
    now, I have to go there 4 times each DAY..!
    I am not saying you should revert to the old style Search bar,
    as I feel that those you are typing search terms are indeed very happy for this new style..
    Instead, I think of 2 possible ways to create happiness also for us that do mark text and choose "Search.."
    1) An "on-the-fly change search engine" option ALSO for when we mark [word] in a text, then right-click, then choose "Search [engine x] for [word]".
    This could work as a cascading menu option, where it says..
    Search for [word] in -> [engine x]
    ..and where [engine x] was the current default engine, and all the other engines was listed underneath,
    just like the drop-down menu when you switch the default engine.
    Additionally, you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Change default search engine when choosing another from the drop-down menu"
    THIS would actually be PERFECT.. It would be even much BETTER than in Firefox 33 and earlier..! :-)
    2) If there are things with the first option that don't work (something I've missed etc),
    then maybe you could have an on / off checkbox in the "Options" "Search" tab, where you had this option:
    "Use old-style search bar"
    This would be off by default, but when switched on, it would give us the old Firefox 33 style Search bar.

    Strongly recommend Context Search extension which will solve your problem
    - https://addons.mozilla.org/en-US/firefox/addon/context-search/?src=search

  • Create on-the-fly menu in JSC 2

    Hi everyone,
    How to create an on-the-fly menu in JSC 2? the on-the-fly menu is something like the menu bar on this Sun Developer Netowork page. When you move a mouse over a link such as APIs, Downloads, and Technologies, there is a menu shown up.
    A sample code would be perfect.
    Thanks in advance,

    The Sun Developer Network page uses javascript to display on-the-fly menus.
    Browsers usually provide ways to view the source code of any HTML page. The instructions to view them will of course vary for different browsers. For mozilla1.4, You can do 'View | Page Source' to see which javascripts are used. You can also select the 'View | Page Info' menuitem, select the 'Privacy' tab and expand 'Scripts' to get the URLs of the scripts used in that page.
    The menucode used in Sun Developer Network page is http://forum.sun.com/jive/js/menucode.js.
    The following are the resources suggested by mozilla.org for javascript:
    http://www.mozilla.org/js/
    http://www.mozilla.org/js/scripting/
    You can of course obtain a lot of free javascripts from the web; for dynamic menus you might want to check out 'http://www.softcomplex.com/products/tigra_menu/'

  • Creating on the fly dynamic named bind variable names.

    I have an application process which gets called by a Dynamic action and Javascript.
    Everything is working great however I'm using it to drive dynamic charts.
    I could use IF statements at the end of the application process to decide what BIND vairable to fill with the information the process has collected however I'd prefer just to create the BIND variable from the
    name of the submitted information.
    So I have an application level variable called WHICHCHART. this gets populated with text upon calling the application process...so let's say 'chart1' is what it gets filled with.
    What I"d like to have at the end of the application process is just a bind variable waiting called :chart_1.
    So no matter what the value of WHICHCHART it will create an on the fly a bind variable with the same name.

    Ok. I guess this question was more how do you do this..then OH NO there are not other ways to do this.
    So I have a page with a chart region. this chart will have 3 Y Axes which prohibits the use of the default XML.
    So..
    I have the following Javscript:
    function getdata(whichchart) {
      var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=VM_XML_GENERATION',0);
            get.add('WHICHCHART',whichchart);
            gReturn = get.get('XML');
      get = null;
    Which is called when the page loads by a dynamic action:
    getdata('production');
    When the javascript is called as you can see it fires off:
    declare
       chart_series_data VARCHAR(32767);
       type array_cols is varray(7) of varchar2(100);
       array array_cols := array_cols('VM_HOSTS_NUM','VM_NUMBER','VM_PHYS_MEM','VM_VIRT_MEM','VM_CPU_COUNT', 'VM_TOTAL_DISK','VM_PROVISIONED_DISK');
    BEGIN
    --IF :WHICHCHART IS NULL THEN
    --RAISE_APPLICATION_ERROR(-20001,'Chart variable not set');
    --END IF;
    chart_series_data := null;
    chart_series_data := '      <data>'||chr(10);
    chart_series_data := chart_series_data||  '        <series name="Hosts Number" type="Line" color="0x1D8BD1" >'||chr(10);
    for c1 in (SELECT VM_REPORT_DATE LABEL,VM_HOSTS_NUM from TABLE where VM_REPORT_DATE between add_months(SYSDATE,-24) and SYSDATE and lower(VM_DCNAME)=lower(:WHICHCHART) )
    loop
    chart_series_data := chart_series_data || '<point name="'||c1.LABEL||'" ';
    chart_series_data := chart_series_data || 'y="'||c1.VM_HOSTS_NUM||'"></point> '||chr(10);
    end loop;
    chart_series_data := chart_series_data|| '      </series>'||chr(10)||'</data>';
    :PROD_DATA := chart_series_data;
    END;
    The : production variable at the end of this I want to change the name of based on the value I'm sending of WHICHCHART from the javascript. I hope this is clearer now.
    AGAIN this is not really a need. It is a want to be able to create dynamic bind variable names going forward.
    Thanks

  • Make a color in image transparent on the fly

    Hi I am trying to load an image and at runtime pick the white
    background of the image as transparent. Can any one point me to the
    flex/flash libraries that may help w/ this? basically I have 2
    images both of them have white background. I want to be able to
    drag and drop them so that the main objects of the images are side
    by side. But the problem is each image has thick white borders. so
    i figure if i can dynamically choose white color in the image to be
    transparent then I can overlap them and the white borders will be
    transparent and won't get in the way. Any expert can point me to
    the right direction?

    doug777, thanks for the reply. My issue is that the image I
    am trying to place next to each other is some images off the web
    i.e. I don't have control over the image transparent color. that's
    why I want to find a way to on the fly set which color in the
    images will be transparent. I was hoping flex has some library for
    that

  • Can you add hyperlinks to the images created in the slideshow on the command menu?

    can you add hyperlinks to the images in the slideshow created
    from the command menu? thanks

    On 30 Aug 2008 in macromedia.fireworks, mediastream13 wrote:
    > can you add hyperlinks to the images in the slideshow
    created from
    > the command menu?
    Unfortunately, those slideshows aren't all that flexible. I
    don't think
    that Adobe supplies the source for the Flash slideshows. But
    if you use
    the spry slideshow, you should be able to edit the HTML in
    Dreamweaver to
    add links.
    Have a look at one of Project Seven's graphics presentation
    products -
    Lightshow Magic, Slide Show Magic or Image Gallery Magic.
    They're $95
    each, and extremely flexible in what you can do with them.
    http://projectseven.com/
    Joe Makowiec
    http://makowiec.net/
    Email:
    http://makowiec.net/contact.php

  • Inserting into a table which is created "on the fly" from a trigger

    Hello all,
    I am trying to insert into a table from a trigger in Oracle form. The table name however, is inputted by the user in am item form.
    here is what the insert looks like:
    insert into :table_name
    values (:value1, :value2);
    the problem is that forms does not recognize ::table_name. If I replace :table_name with an actual database table, it works fine. However, I need to insert to a table_name based from oracle form item.
    By the way, the table|_name is built on the fly using a procedure before I try to insert into it.
    Any suggestion on how can I do that? My code in the trigger is:
    declare
    dm_drop_tbl(:table_name,'table) // a call to an external procedure to drop the table
    dm_create_tbl(:table_name,'att1','att2');
    insert into :table_name
    values (:value1, :value2);
    this give me an error:
    encounter "" when the symbol expecting one.....

    Hi ,
    You should use the FORMS_DDL built_in procedure. Read the on-line documentation of forms ...
    Simon

  • Can't find how to create on-the-fly playlists using search

    I used to make ad-hock playlists on the fly using the quick search in iTunes 10:I would display a list of songs (the full library or from a play list), type somethings in the quicksearch box, and the list would narrow down to the search results, where then I could simply hit "play" and use these results as a temporary ad-hoc playlist.
    That features seems to be gone- even after getting iTunes 11 to LOOK like iTunes 10, typing any search term will show (partial) results in a drop down menu, not narrowing the display, and no option in a single click to simply play the results.
    Am I missing something? Did Apple really remove that functionality?

    Settings>cellular>cellular data

  • Another attempt to create "on the fly" condition in PL/SQL

    Here is the code:
    ---BEGIN ----
    declare
    my_var_list VARCHAR2(4000);
    cursor my_curr is select aa.column_name as my_col_name from user_tab_columns aa, user_tab_columns bb
    where aa.column_name = bb.column_name
    and aa.table_name = 'MY_SUBSET_TABLE' and bb.table_name = 'MY_SUPERSET_TABLE';
    begin
    for my_ind in my_curr loop
    my_var_list := my_var_list || my_i.my_col_name || ', ';
    end loop;
    insert into MY_SUPERSET_TABLE (my_var_list) select my_var_list from MY_SUBSET_TABLE;
    end;
    run;
    ---END---
    I plan to extract column name from user_tab_column, and concat it into a variable "my_var_list".
    The question now is, given the my_var_list contain column names (separate by comma), how can I use it in the select statement below?
    insert into MY_SUPERSET_TABLE (my_var_list) select my_var_list from MY_SUBSET_TABLE;
    Any idea on how to improve this script? I am running on Oracle9i ... using SQL Dev.
    Thanks much...

    It's a terrible idea, but it can be done. It could leave you open for sql injection hacks:
    declare
    my_sql VARCHAR2(4000);
    column_list varchar2(4000);
    v_iteration number := 0;
    begin
    for i in ( select column_name from user_tab_columns where table_name = 'T1') loop
    if v_iteration = 0 then
    column_list := i.column_name;
    else
    column_list := column_list||','||i.column_name;
    end if;
    v_iteration := v_iteration + 1;
    end loop;
    execute immediate 'insert into t2('||column_list||') select '||column_list||' from t1';
    end;
    /

  • Obtaining Screenshot from Spectrum Analyzer - Not able to view the image created

    Hello,
    I am using the following code snippet in my program to get the screen shot from  Agilent Spectrum Analyzer , I am able to get a gif image created in the location specified but when i opened it I could not see any result.
    Please help out . I also tried with Interactive Utility still the same result , Am i missing something here or is there anything for me understand . please let me know.
    ibwrt(DeviceHandle,":MMEMTORCR 'CICTURE.GIF'",30);
    ibwrt(DeviceHandle,":MMEMATA? 'CICTURE.GIF'",28);
    ibrdf(DeviceHandle,"C:\\PICTURE.GIF");
    Thanks
    Meeran

    Dear Bala,
    I have got about 8 to 10 DC's out of which only this one is showing the missing structure and as this dc is being used by other dc's I am getting the error like missing component.  Previously we were using the client desktop and doin the work now we have shifted it to our individual systems.  Now any project I am creating whether from same track or different same problem comming the structure is missing.
    Regards,
    Ganesh
    Edited by: Ganesh Sawant on Sep 8, 2009 9:42 AM

  • Print images in PNG and BMP formats

    I have converted images from xwd to bmp by using JAI. now I want to print them.
    How can I print PNG and BMP Files? How can I read images in different formats and make them print.
    Please help me !

    JAI follows the Java 2D printing model. All you need to do is to read your PNG, BMP images as RenderedImage, Renderable, or BufferedImage objects. To print an image, draw the image object on the printer's graphics context using one of drawImage(), drawRenderedImage(), and drawRenderableImage() methods of the Graphics2D class.
    I have some sample code at http://www.geocities.com/larryhr/samplecode/samplecode.html. See the Printing section. JAIImagePrint.java should give you some indication as to how to print images read by the JAI codec.

  • Rotate Image Created with createImage() ?

    I've been looking around online for a way to do this, but so far the only things I have found are 50+ lines of code. Surely there is a simple way to rotate an image created with the createImage() function?
    Here's some example code with all the tedious stuff already written. Can someone show me a simple way to rotate my image?
    import java.net.*;
    import java.awt.*;
    import java.awt.geom.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class RotImg extends JApplet implements MouseListener {
              URL base;
              MediaTracker mt;
              Image myimg;
         public void init() {
              try{ mt = new MediaTracker(this);
                   base = getCodeBase(); }
              catch(Exception ex){}
              myimg = getImage(base, "myimg.gif");
              mt.addImage(myimg, 1);
              try{ mt.waitForAll(); }
              catch(Exception ex){}
              this.addMouseListener(this);
         public void paint(Graphics g){
              super.paint(g);
              Graphics2D g2 = (Graphics2D) g;
              g2.drawImage(myimg, 20, 20, this);
         public void mouseClicked(MouseEvent e){
              //***** SOME CODE HERE *****//
              // Rotate myimg by 5 degrees
              //******** END CODE ********//
              repaint();
         public void mouseEntered(MouseEvent e){}
         public void mouseExited(MouseEvent e){}
         public void mousePressed(MouseEvent e){}
         public void mouseReleased(MouseEvent e){}
    }Thanks very much for your help!
    null

    //  <applet code="RotationApplet" width="400" height="400"></applet>
    //  use: >appletviewer RotationApplet.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.AffineTransform;
    import java.awt.image.BufferedImage;
    import javax.swing.*;
    public class RotationApplet extends JApplet {
        RotationAppletPanel rotationPanel;
        public void init() {
            Image image = loadImage();
            rotationPanel = new RotationAppletPanel(image);
            setLayout(new BorderLayout());
            getContentPane().add(rotationPanel);
        private Image loadImage() {
            String path = "images/cougar.jpg";
            Image image = getImage(getCodeBase(), path);
            MediaTracker mt = new MediaTracker(this);
            mt.addImage(image, 0);
            try {
                mt.waitForID(0);
            } catch(InterruptedException e) {
                System.out.println("loading interrupted");
            return image;
    class RotationAppletPanel extends JPanel {
        BufferedImage image;
        double theta = 0;
        final double thetaInc = Math.toRadians(5.0);
        public RotationAppletPanel(Image img) {
            image = convert(img);
            addMouseListener(ml);
        public void rotate() {
            theta += thetaInc;
            repaint();
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                RenderingHints.VALUE_INTERPOLATION_BICUBIC);
            double x = (getWidth() - image.getWidth())/2;
            double y = (getHeight() - image.getHeight())/2;
            AffineTransform at = AffineTransform.getTranslateInstance(x,y);
            at.rotate(theta, image.getWidth()/2, image.getHeight()/2);
            g2.drawRenderedImage(image, at);
        private BufferedImage convert(Image src) {
            int w = src.getWidth(this);
            int h = src.getHeight(this);
            int type = BufferedImage.TYPE_INT_RGB; // options
            BufferedImage dest = new BufferedImage(w,h,type);
            Graphics2D g2 = dest.createGraphics();
            g2.drawImage(src,0,0,this);
            g2.dispose();
            return dest;
        private MouseListener ml = new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
                rotate();
    }

  • SUM function for a column made 'on the fly'

    I have access to a database, however only SELECT statements can be run on the database. Basically the database lists switches, these switches can have up to 20 computers connected to them but some do not. I need to know the switches which contail less than 20 computers so I know where there is space for more computers (I've wrote the code for this already). I also need something to keep a tally/total for the number of spare spaces left so I can run the script and go 'ok we have a total of 20 spare places for computers theres 10 on this switch and 10 on this one'.
    I just need to get the sum funtion working for the column that I've created 'on the fly', the column revealing the number of spare slots, heres the code I've got so far:
    SELECT switch, COUNT(*) as "Servers", 20 - COUNT(*) as "Spare slots"
    from dedicated_servers
    where switch like 'rs%'
    GROUP by switch
    HAVING COUNT(switch) < 20
    order by Servers;
    Which gives the following:
    | switch | Servers | Spare slots |
    | rsj14-1.dc | 12 | 8 |
    | rsj12-1.dc | 15 | 5 |
    | rsi2-2.dc | 16 | 4 |
    | rsj13-1.dc | 16 | 4 |
    | rsi2-1.dc | 16 | 4 |
    Just need something at the end saying TOTAL=25

    OK I'll have to make em up though, but they are something like this for one switch:
    INSERT INTO dedicated_servers (switch, server_number, switch_socket)
    VALUES (rsj-1.dc, 100, 18)
    On switch rsj-1.dc there can be upto 20 servers (the server_number is the primary key)
    Message was edited by:
    slowpoke115

  • Can Access DRM encryption be applied on the fly?

    Hi,
    ... and thanks in advance for responding. I have the following questions:
    Can Access DRM-Core and Access DRM-Pro encryption be applied to a video file "on the fly" for RTMP?  (I'm not interested here in Access Protected Streaming)
    How about for HDS?
    How about for HLS?
    By "on the fly", I mean at the time the request was made from the client and as a prelude to the  response from the media server. This would allow us to avoid creating and storing an Access encrypted representation of the video in advance.
    Thanks!

    There are a couple ways to generate just the "DRM Headers" without having to encrypt the whole file.
    1. If you're an Adobe Broadcast Licensee, with access to our Broadcast SDK (HDKb), there are APIs in there to just generate the DRM Metadata.
    2. If you have a recent version of AMS, the f4fpackager tool that comes with the product has had a recent revision where you can update an existing F4M (manifest) file to include a new DRM Metadata, which is created on the fly.  I'm not sure if this new f4fpackager tool has been released yet in the latest AMS, however.
    Besides those routes, the only other way to create a DRM Metadata would be to package an entire video.
    cheers,
    /Eric.

Maybe you are looking for

  • Voice Memos not syncing to iTunes after installing OS 4.3.3 on iPhone 4

    All the voice memos I've recorded on my iPHone 4 since installing 4.3.3 are not syning to my iTunes Library. Any ideas on what to do and how to get them off the phone?

  • ICal with iCloud syncing - how to back up

    Like many others, I have had problems with multiple entries on iCal. In my case, i probably stuffed up trying to fix it. I ended up with duplicate calendar items before I switched off mobile me. I also updated iPad and iPhone 4 with OS5 thinking i co

  • How can I stop Firefox from opening pdfs in Google Docs?

    Whenever I want to look at or download a webspage which is a Microsoft Word or a pdf document, I am automatically sent to Google Docs to view it. Mayvbe bexcauuse of my satellite connection, I cthen have huge problems in downloading these webpages. H

  • What is KCV (Key Check Value) in 3DES used for?

    Hi Friends.. I want to know what is KCV (Key Check Value) used for?.. i found that 3DES operation (2Keys length or 3Keys length) sometimes needs KCV (Key Check Value).. As far as i know the KCV itself computed as Follows : 3DES(Keys, IV(all zeroes),

  • Authentication Web Services for Java applications

    Hi All, We are building Java based SAP applications for mobile devices such as Blackberry, iPhone etc. The applications are browser based (thin client) to be deployed on SAP Netweaver WAS and would interface with SAP backends such as SAP ECC, SAP BW