Generating images on the fly to use as backgrounds for components

I am creating an application that has an input number slider with a background image. I would like to change the background image on the slider based on its position (as chosen by the user) using a partial trigger.
I have successfully been able to do update the background images if I have these images inside of my "Web Content" folder within my JDeveloper project. Instead, I would like to be able to generate the images as needed. These images are color gradients where the start/stop of the gradient is based on the slider's thumb position (as well as other user-defined variables). Because there are many different images that could possibly be created, I am looking into generating the images at runtime rather than have hundreds of images stored somewhere.
I am trying to generate these images using a BufferedImage that I can then write to a file. The path I am saving it at is as follows:
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext)fc.getExternalContext().getContext();
String path = sc.getRealPath("/") + filename;
I then create the file at the path and use ImageIO to write it:
File f = new File(path);
ImageIO.write(bi, "png", f);
I am saving this file path in a variable in my backing bean that I then use on my ADF page to populate the background image field of the slider.
Problem: when I run the page, my slider does not have a background image.
Looking at the location where the file should be saved, it is actually "saving" it within a .war file which I don't think is appropriate (or possible, for that matter). Is there some way that I can save it either on the server side or the client side so that the client can see the background actually being updated using the generated image? I am almost positive that the path I listed above is incorrect - if this is the correct approach for this problem, where would be an appropriate location?
Any pointers would be greatly appreciated. Thanks in advance for your help!

Instead of saving the image to a file, why not use a Servlet to write the image to the Servlet's response stream. Then, you just point the background image to the Servlet.
John

Similar Messages

  • Problem in drawing image on the fly using jsp

    I have been searching the forum and web for the problem but in vain. I have wrote a jsp which creates an image on the fly from the data selected from the database. But after the image is drawn, it throws an IllegalStateException. The offending code is at the time of releasePageContext() method of the compiled jsp. I am using the following code in jsp to display the image.
    BufferedImage bi = obj.getBufferedImage();
    javax.imageio.ImageIO.write(bi,"png",response.getOutputStream());
    I even tried to do the same with servlet, but the problem is that when I am using forward action in jsp I am getting the image but the control is in the servlet and if I am including the servlet, I am getting junk characters instead of image. I have set the content type in servlet and also in jsp.
    Thank you in advance.

    Hi all,
    I've developed a web application using glassfish server... my database is postgresql.... i try to generate a report using Jasper Reports.... i've succesfully developed the report template..... My problem when ever i try to generate a report it gets the data from the back end.... and throws the following error.....
    StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    java.lang.IllegalStateException: getOutputStream() has already been called for this response
    at org.apache.coyote.tomcat5.CoyoteResponse.getWriter(CoyoteResponse.java:652)
    at org.apache.coyote.tomcat5.CoyoteResponseFacade.getWriter(CoyoteResponseFacade.java:196)
    at org.apache.jasper.runtime.JspWriterImpl.initOut(JspWriterImpl.java:149)
    at org.apache.jasper.runtime.JspWriterImpl.flushBuffer(JspWriterImpl.java:142)
    at org.apache.jasper.runtime.PageContextImpl.release(PageContextImpl.java:216)
    at org.apache.jasper.runtime.JspFactoryImpl.internalReleasePageContext(JspFactoryImpl.java:134)
    at org.apache.jasper.runtime.JspFactoryImpl.releasePageContext(JspFactoryImpl.java:89)
    at org.apache.jsp.GenerateBirthCertificate_jsp._jspService(GenerateBirthCertificate_jsp.java:149)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:353)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:409)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:317)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    i've written my code in jsp.... My code is....
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@ page language="java" import="java.io.*, net.sf.jasperreports.engine.*, java.sql.*, java.util.*" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>CDAC Portal</title>
    </head>
    <body>
    <%
    try {
    Connection con=null;
    String query="";
    String regNo="";
    regNo=request.getParameter("regNo");
    regNo = regNo.toUpperCase();
    out.println("Registration No :"+regNo);
    Class.forName("org.postgresql.Driver");
    con = DriverManager.getConnection("jdbc:postgresql://192.168.31.79:5432/Municipality","postgres","");
    System.out.println("connected succefully");
    ServletContext context = this.getServletConfig().getServletContext();
    File reportFile = new File(context.getRealPath("/reports/birth_cert.jasper"));
    query="select * from birth_details where regn_unit='"+regNo+"'";
    Map parameters = new HashMap();
    parameters.put("regNo",""+regNo);
    parameters.put("query",""+query);
    byte[] bytes = null;
    try {               
    bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, con);
    response.setContentType("application/pdf");
    response.setContentLength(bytes.length);
    ServletOutputStream ouputStream = response.getOutputStream();
    ouputStream.write(bytes, 0, bytes.length);
    ouputStream.flush();
    ouputStream.close();
    } catch (JRException e) {
    System.out.println("Error : "+e);
    con.close();
    } catch(Exception exc) {
    System.out.println("Connection pool error :"+exc.toString());
    %>
    </body>
    </html>
    can anyone help me hw to solve this problem....
    Thanks in advance
    R Vijay,
    Project Engineer,
    CDAC, Chennai.
    India
    [email protected]
    [email protected]

  • Want to store and retrived  images  in the BFILE format using inter media

    I want to store and retrived images in the BFILE format using inter media.I found a article in the oracle site that Oracle interMedia image supports BFILEs.But this article is not demonstrating the use of BFILEs.Please help me to findout the solution.
    Thanks in advance.
    null

    The advantage to using BFILE storage for your is that it's an easy way for Oracle
    Multimedia to access your images without importing them into the database.
    The disadvantages are that the images are read-only. If you want to scale an image or
    convert to a different format, you will need to create a destination image to hold the result. This
    will necessarily be a BLOB based image.
    Adding images is difficult to do from within an application program. Generally you would add new images to a file system that is accessible to the Oracle Database, then insert new rows in your table with appropriate BFILE pointers to the new images.
    BFILE images require separate backup from the database. Also there is not way to transactionally coordinate your BFILE data with your relational data.
    If you are using Oracle 11g, you can use the SecureFile option for BLOB storage. This is much faster then the previous BLOB storage (now called BasicFile) and much faster then BFILE also.
    That said, below is a code snippet that shows how to insert a BFILE based image, set it's properties, show it's properties and select the BFILE locator to access the content. You would need to use the DBMS_LOB package (in PL/SQL) to read the content. From other APIs, (e.g., Java) you would need to use the proper interfaces to access the BFILE.
    Note that you need change the USER, PASSWORD fields in the code. Also you should change the directory location and image name for your use.
    -- create a directory object indicating where the images are stored;
    create or replace directory imgdir as '/tmp';
    -- and grant permission to read to a user;
    grant read on directory imgdir to <USER>;
    conn <USER>/<PASSWORD>;
    -- create the images table
    create table images(id integer primary key, image ordsys.ordimage);
    set serveroutput on
    declare
    obj ordsys.ordimage;
    begin
    -- use the init('FILE', <SRC_LOCATION>, <SRC_FILE>) function
    -- to create an ORDIMAGE object with a BFILE source
    insert into images(id, image)
    values(1, ordimage.init('FILE', 'IMGDIR', 'wizard.jpg'))
    returning image into obj;
    -- lets see if the image source is local or not
    if(obj.isLocal()) then
    dbms_output.put_line('image source is local');
    else
    dbms_output.put_line('image source is NOT local');
    end if;
    -- set the properties of the image object
    obj.setProperties();
    -- and update the row
    update images set image=obj where id=1;
    commit;
    end;
    column height format 99999
    column width format 99999
    column mimetype format a30
    column length format 999999
    -- let's see what we have
    select t.image.getHeight() as "height"
    , t.image.getWidth() as "width"
    , t.image.getMimetype() as "mimetype"
    , t.image.getContentLength() as "length"
    from images t
    -- fetch a BFILE handle to the content
    declare
    bf BFILE;
    length number;
    begin
    select t.image.getBfile() into bf
    from images t
    where t.id=1;
    -- use the DBMS_LOB interface to find out size of image
    length := dbms_lob.getLength(bf);
    dbms_output.put_line('length of BFILE is ' || length);
    end;
    ---What we get when we run the code
    Connected.
    Directory created.
    Connected.
    Table created.
    image source is NOT local
    PL/SQL procedure successfully completed.
    height     width mimetype               length
    399     485 image/jpeg          92552
    length of BFILE is 92552
    PL/SQL procedure successfully completed.
    SQL>

  • Steps to load the data by using flat file for hierarchies in BI 7.0

    Hi Gurus,
    steps to load the data by using flat file for hierarchies in BI 7.0

    hi ,
    u will get the steps int he following blog by Prakash Bagali
    Hierarchy Upload from Flat files
    regards,
    Rathy

  • My ipad 2's battery percentage is stuck at 95%!!! Eventhough I charge 5 hours, it is still 95%...After that, I unplugged the charger, I use my ipad for 3 hours, it is still 95%!!!!! What's wrong is it?! HELP ME

    My ipad 2's battery percentage is stuck at 95%!!! Eventhough I charge 5 hours, it is still 95%...After that, I unplugged the charger, I use my ipad for 3 hours, it is still 95%!!!!! What's wrong is it?! HELP ME

    You probably need to recalibrate the battery. See link below.
    Try this first - Reset the iPad by holding down on the Sleep and Home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons. (This is equivalent to rebooting your computer.)
    The quickest way (and really the only way) to charge your iPad is with the included 10W or 12W (5W on Mini) USB Power Adapter. iPad will also charge, although more slowly, when attached to a computer with a high-power USB port (many recent Mac computers) or with an iPhone Power Adapter (5W). When attached to a computer via a standard USB port (2.5W, most PCs or older Mac computers) iPad will charge very slowly (but iPad indicates not charging). Make sure your computer is on while charging iPad via USB. If iPad is connected to a computer that’s turned off or is in sleep or standby mode, the iPad battery will continue to drain.
    Apple recommends that once a month you let the iPad fully discharge & then recharge to 100%.
    How to Calibrate Your Mac, iPhone, or iPad Battery
    http://www.macblend.com/how-to-calibrate-your-mac-iphone-or-ipad-battery/
    At this link http://www.tomshardware.com/reviews/galaxy-tab-android-tablet,3014-11.html , tests show that the iPad 2 battery (25 watt-hours) will charge to 90% in 3 hours 1 minute. It will charge to 100% in 4 hours 2 minutes. The new iPad has a larger capacity battery (42 watt-hours), so using the 10W charger will obviously take longer. If you are using your iPad while charging, it will take even longer. It's best to turn your new iPad OFF and charge over night. Also look at The iPad's charging challenge explained http://www.macworld.com/article/1150356/ipadcharging.html
    Also, if you have a 3rd generation iPad, look at
    Apple: iPad Battery Nothing to Get Charged Up About
    http://allthingsd.com/20120327/apple-ipad-battery-nothing-to-get-charged-up-abou t/
    Apple Explains New iPad's Continued Charging Beyond 100% Battery Level
    http://www.macrumors.com/2012/03/27/apple-explains-new-ipads-continued-charging- beyond-100-battery-level/
    New iPad Takes Much Longer to Charge Than iPad 2
    http://www.iphonehacks.com/2012/03/new-ipad-takes-much-longer-to-charge-than-ipa d-2.html
    Apple Batteries - iPad http://www.apple.com/batteries/ipad.html
    iPhone: Hardware troubleshooting (Power/Battery section also applies to iPad)
    http://support.apple.com/kb/TS2802
    Extend iPad Battery Life (Look at pjl123 comment)
    https://discussions.apple.com/thread/3921324?tstart=30
    iOS 7 Battery Life Draining Too Fast? It’s Easy to Fix
    http://osxdaily.com/2013/09/19/ios-7-battery-life-fix/
    New iPad Slow to Recharge, Barely Charges During Use
    http://www.pcworld.com/article/252326/new_ipad_slow_to_recharge_barely_charges_d uring_use.html
    iPad: Charging the battery
    http://support.apple.com/kb/HT4060
    Best Practices for iPad Battery Charging
    http://www.ilounge.com/index.php/articles/comments/best-practices-for-ipad-batte ry-charging/
    Tips About Charging for New iPad 3
    http://goodscool-electronics.blogspot.com/2012/04/tips-about-charging-for-new-ip ad-3.html
    How to Save and Prolong the battery life of your new ipad
    https://discussions.apple.com/thread/4480944?tstart=0
    Prolong battery lifespan for iPad / iPad 2 / iPad 3: charging tips
    http://thehowto.wikidot.com/prolong-battery-lifespan-for-ipad
    iPhone, iPod, Using the iPad Charger
    http://support.apple.com/kb/HT4327
    Install and use Battery Doctor HD
    http://itunes.apple.com/tw/app/battery-doctor-hd/id459702901?mt=8
    To Extend a Device’s Battery Life, Get to Know It Better
    http://tinyurl.com/b67c7xz
    iPad Battery Replacement
    http://www.apple.com/batteries/replacements.html
    In rare instances when using the Camera Connection Kit, you may notice that iPad does not charge after using the Camera Connection Kit. Disconnecting and reconnecting the iPad from the charger will resolve this issue.
     Cheers, Tom

  • Hi , We are in 11.5.10.2, recently, one of our OU was sold but still we have given the option to use our system for 6 months inorder to support their business. Now, we dont want those receivables transactions to be posted to out company accounts.

    Hi , We are in 11.5.10.2, recently, one of our OU was sold but still we have given the option to use our system for 6 months inorder to support their business. Now, we dont want those receivables transactions to be posted to out company accounts.
    How to handle this situation in oracle now.

    How To: Direct Message  and  ArnettH_VZW

  • How do I get rid of the message "To use this machine for downloads, enter you Apple ID and password" which I now see twice since I downloaded the latest version of iTunes? Once is enough and no checkbox exists to say "do not show this message.....".

    When I start iTunes, how do I get rid of the message "To use this machine for downloads, enter you Apple ID and password" which I now see twice since I downloaded the latest version of iTunes.  Once is enough and no checkbox exists to say "do not show this message....."

    Does this apply?
    If you're asked for the password to your previous Apple ID when signing out of iCloud - Apple Support

  • How are the .7z files used and installed for photoshop elements and premier elements?

    How are the .7z files used and installed for photoshop elements and premier elements?

    Hi,
    You can try to extract them to a folder and then try to install using the setup file.
    Or you can try to download the .exe file ( Small File ) for the software you have and then run the .exe file and it will start the installation. Both .exe and .7z file for the application should be in same location.
    Download Photoshop Elements products | 9, 8, 7
    Download Photoshop Elements products | 11, 10
    Download Premiere Elements products | 11, 10
    Download Premiere Elements products | 9
    *** You can either download the .exe file from the above download links or you can also download both .exe (File 2 of 2) and .7z (File 1 of 2) from the above links.

  • HT204053 How does my spouse get the benefits of using my iCloud for contacts and calanders but not messages, etc?

    How does my spouse get the benefits of using my iCloud for contacts and calanders but not messages, etc?

    iCloud is designed for personal use and not for managing multiple access.  If you gives your password to someone else, this person can benefit everything including access to purchase with your account, email, etc.
    You should rather consider having each one an iCloud account and then, create and share a calendar.  As for contact, you can send them to your spouse to be save in her account but they cannot be shared nor synced.

  • Both my daughter and I have iPhones. How do I get my daughters number off my iPad permanently? I don't even want the option to use her number for iMessages.

    Both my daughter and I have iPhones. How do I get my daughters number off my iPad permanently? I don't even want the option to use her number for iMessages.

    For starters, you should not be using the same Apple ID. Are you?

  • HT201412 while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    while using sometimes my iphone 5stops working and shows the apple logo with white background for 5 seconds and in short time it returns to home screen.please solve it

    Hi there bencong111,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/TS3281
    -Griff W. 

  • How to create thumbnail images on the fly from JSP or servlet?

    Hi all,
    Iam new to this forum. I need a solution for the problem iam facing in building my site. Ihave groups and briefcase section in my site. I allow users to upload files and pictures.
    When they upload pictures i need to create thumbnail for them on the fly.
    Is there any taglibs or java source to do this from JSP or servlets.
    It would be very greatful if i can get an early answer.
    Please let me know if there is any other forum where i can get better answer, if not here?
    thnx.

    Here is how you can create dynamic images:
    http://developer.java.sun.com/developer/JDCTechTips/2001/tt0821.html#tip2
    However, if you want to create gifs/jpegs and save them to the disk it depends from where you want to create the images. It is different if you are creating from another image or just drawing one from scratch etc.. But in the end you will probably need to use one of the imageencoder classes and write the result to the disk with the file io classes.

  • 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

  • How can I simultaneously acquire and display an image on the front panel using a PCI-1424

    Dear friends;
    I want to use PCI-1424  , and labview 5.1 to capture the image,  But I can not find some functions in labview to capture, display and save the image.Can you be kind to share some examples or provide some information.
    Another question is how I CAN display the image in the front panel.
    thanks so much

    Hello yangshang,
    Thank you for contacting National Instruments!  To acquire images from the 1424 you will need NI IMAQ 2.5.1 or later.  This can be found HERE on our drivers download page.  One thing to note is that in LabVIEW 5 we only had the ability to view an IMAQ image as a pop up window.  This VI is called "IMAQ Windraw".  This will pop up a separate window that will display your picture.  If you need to view the picture on the front panel you can try saving the image as a file (BMP, JPG, etc) then use the LabVIEW Graphics and Sound VI's to Read a picture file in and then wire the picture to a picture control on the front panel.  Let me know if you have anymore questions.  Good Luck.
    Regards,
    Mark T
    Applications Engineer | National Instruments

  • Save canvas as image to the picture library using c#,xaml in windows 8.1

    Hi everyone,
    I am developing a small paint application in that I am using canvas as a drawing area. Now I need to save that drawing as an image to the picture library.
    How can I do this?
    Please help me.
    Thanks in advance

    Use RenderTargetBitmap to render your Canvas into a bitmap. Use BitmapEncoder to encode the bitmap as a JPG or png, then save it our with a StorageFile.
    See the sample at
    http://code.msdn.microsoft.com/windowsapps/XAML-render-to-bitmap-dd4f549f

Maybe you are looking for

  • Boot Camp keeps stopping at partition step

    Hi guys, I'm trying to run windows on my iMac 27" (Mid 2010) running 10.7.3  and everytime I get to the partioning step, I choose how much I want to dedicate to windows and it will run for a few minutes and then say "Back up the disk and use Disk Uti

  • Battery Failure and Kernel Panics. Help!

    Hi all, Thanks in advance for your help. About a week ago, after I had left my computer alone for two days, it randomly shut off when the meter up top said it had 40 minutes. Then, when it was closed in sleep mode and I opened it, it told me it had t

  • Files panel context menu

    is it possible to add search options to the files context menu ? like start dw search with selected folder ? i know how to edit dw menus ... thanks pi

  • Still no joy with loading files into my application

    I am still getting all kinds of exceptions when trying to load a file of album objects, into my Album array. I am getting an Index out of Bounds object even when i fill the array up to the set size, I am getting a null pointer exception even when i h

  • HT1751 I just loaded some songs off of a cd. How do I sync to ipod?

    I just loaded some songs off a cd. How do I sync to i pod?