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.

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]

  • How to create reports online on the fly using meta-data.

    We have dataset and blank report. How can I create report design on the fly ? so that it will able to display report dataset.
    Can someone tell me it is possible or not ? or some reference links....

    Hello,
    This can be certainly done by executing a script written using Report Application Server (RAS) SDK.
    Please refer the link : [http://devlibrary.businessobjects.com|http://devlibrary.businessobjects.com] for detailed documentation on the usage of RAS SDK.
    Regards,
    Chinmay Athavale
    Edited by: Chinmay1009 on Jul 27, 2010 3:46 PM

  • How to upload files/images to the database from a form.

    I'm making a custom user profile form.
    The users can update their profile in this form.
    I cannot use the standard profile form, because the customer got very specific
    demands about the context of the profile form.
    In this custom profile form the user must be able to upload an image
    from their hard disk(just like in the standard profile form).
    I've got the following questions about uploading pictures:
    - How do I make a button to show the explorer window.
    - how do I get the chooses file-name in a field.
    - how do I get the new file in the database.
    - how do I get rid of an old file in the database.
    - how do I get the image on the form.
    Or is there a special portal way to upload images/files in a form.
    Does anyone have a clue?
    regards
    arny

    Hi,
    Regular Portal forms will support upload of images/documents to the database. Just identify your column as a blob, and the 'Browse' button will automatically show up in the form and the users will get to choose the file they want to upload from their desktop.
    The thing is, I haven't been able to figure out how to get that document/image back out of the database (e.g. in a report), once it's put in. Maybe someone else can answer that.

  • How to create new instance of the process from external web apps?

    Hi Everyone,
    How to create a new instance of the process which deploy to the weblogic server from the external web app?
    Thank you.

    Assuming the process includes a message start event, the simplest way is to use Web Service call. Once you've deployed the process you can use Enterprise Manager to get the URL of the WSDL. There's and icon at the top of the composite summary page for getting the WSDL, or you can get it from the test page. Use that WSDL URL to construct the client to use from the web app. If it's an ADF client you can generate either an ADF Data Control or a client proxy.

  • How to send data (file and text both) from jsp to servlet

    upload JSP 
    case 1>> if i am using this  <form enctype="multipart/form-data" the file value is comming on the servlet side
             and other vales are not comming when i am using request.get parameter(....);
    case 2>>  if i am using this <form  type="text/html" the "submissionperiod" and "Types" value is comming on the servlet but the file is not comming ........
         How to resolve this issue .  i need to send all the three parameter on single submit and retrieve the parameter values  in my servlet .
    please help !
    <form enctype="multipart/form-data" name="form" method="post" action="Upload" >
                    <table font size="3" style="color:brown;font-family:Arial" >
                    <tr>
                    <td>Submission Year:    </td>
                    <td><select  name="submissionperiod">
                         <option value="">--select--</option>
                         <option value="2000">2000</option>
                         <option value="2001">2001</option>
                         <option value="2002">2002</option>
                         <option value="2003">2003</option>
                         <option value="2004">2004</option>
                         <option value="2005">2005</option>
                         <option value="2006">2006</option>
                         <option value="2007">2007</option>
                         <option value="2008">2008</option>
                         <option value="2009">2009</option>
                    </select><label class="Required">*</label></br></td>
                    </tr>
                    <tr>
                    <td>Submission Type :    </td>
                    <td><select  name="types"   onchange="showDescription()">
                         <option value="">--select--</option>
                         <option value="CRF">CRF</option>
                         <option value="NIR">NIR</option>
                         <option value="NC">NC</option>
                         <option value="SEF">SEF</option>
                    </select><label class="Required">*</label></br></td>
                   </tr>
                   <tr><td></td><td>
                   <div id="divTypeDetails">
                    <textarea  id= "subTypeDes" name="subTypeDes"  value=""></textarea></br></br>
                  </div>
                  </td>
              </table>     
              <td>Select a file (< 100 MB):   </td>
              <td><input id="importFile" name="importFile" type="file"></br>          
              </td>
              <input type="hidden" name="types">
              <input type="hidden" name="submissionperiod">
              <input type="submit" id="submitButton" name="submit" value="Upload" onclick = "checkUploadValidity();"/>
              <input type="button" name=btncancel id=btncancel value="cancel" onclick= "btncancel_click()"/>
    </form> 

    Both the file and text values are included in the binary inputstream of the request. The parametermap is always empty.
    There exist 3rd party API's to parse multipart/form-data streams, such as [Apache Commons FileUpload API|http://commons.apache.org/fileupload].
    Read at least the 'User Guide' and 'Frequently Asked Questions' sections.

  • How to create shortcut programmatically in the mobile from a website using MVC 4

    Hi
    We have created MVC 4 mobile web application, need to create shortcut from code in MVC 4 to mobile device. So that user need not to create shortcut himself/herself in mobile device.
    Thanks in advance.

    This forum is to discuss problems of C# development. Your question is not related to the topic of this forum.
    You'll need to post it in the dedicated ASP.Net Forum
    http://forums.asp.net for more efficient responses, where you can contact ASP.NET experts. Thanks for understanding.

  • Creating Thumbnail Images

    Anyone know how to create thumbnail images on the fly?

    First google:
    http://www.google.co.uk/search?hl=en&q=java+create+thumbnail&btnG=Google+Search&meta=
    Then pick the first link:
    http://schmidt.devlib.org/java/save-jpeg-thumbnail.html

  • How do I create an object on the fly

    Hello there,
         I was wondering if it is possible to create an object on-the-fly. For example:- I have a class called Customer which holds the name, address and phone number of a customer. While the program is running I get a new customer, Mr Brown. How can I create a new Customer object which will hold the details of Mr Brown.
    yours in anticipation
    seaview

    If I understood you right, you are thinking far too complicated.
    So, when you click a button, a new object shall be created and stored. So basically you write a listener to your button that contains a method like this:
    public void actionPerformed(ActionEvent e){
       Customer newCustomer = new Customer(textfield.getText());
       listOfCustomers.add(newCustomer);
    }Maybe what got you confused is the object's name. Remember this: variables and field names DON'T exist anymore at runtime! They are just meant to help you when programming. If you want Mr. Brown as a customer, you have to provide a field in the customer class for the name. If a field is required for the existence of an object, you usually write a custom constructor for it, which accepts an according parameter.

  • How do you show thumbnail images for the contacts?

    How do you show thumbnail images for the contacts on the iPod?
    -Thank You

    In another thread I posted a suggestion to try when the iPhoto app in the Application folder will not work:
    after upgrading the OS, iPhotos (and Aperture for that matter) should still be in the Applications folder...
    And running well in 10.10.3.
    If it stops running in a next "update" do not throw it away: most apps will continue running as follows:
    In the Applications folder "rightclick" (CTL+click) the iPhoto app, then "show package contents", then click the MacOs folder open: you see the real app (dark grey), rightclick this and choose "make alias", an alias is made, move this alias to the Applications folder and use it to run iPhoto.
    Same for Aperture.
    In older OS this survived several upgrades....
    Lex

  • Create Thumbnail Image in KM

    Hello Everybody,
    I can upload images to KM Folders. But I want to create thumbnail image while i am uploading original image. I found one library but i cant call the create function from "com.sapportals.wcm.repository.manager.thumbnail.ResourceImageThumbnailPlugIn" library.
    Does anyone know how can i call this function from webdynpro?
    Kind Regards.
    Rasim

    Hello,
    You are right john. But i am using KM api library from webdynpro. I dont use km upload tool. for that reason it cant create thumbnail automatically. I need one library for creating thumbnails.
    Thanks satish for your link. But i dont understand what should i do with this link. My problem is if i uploaded jpg images, it cant created thumbnails automatically..

  • How to create transparent image at run-time?

    How to create transparent image at run-time? I mean I want to create a (new) transparent image1, then show other (loaded) transparent image2 to image1, then show image1 to a DC. The problem is - image1 has non-transparent background...

    i'm not sure, but you can set the alpha value to 0 in all pixels which are 'in' the background..
    greetz
    chris

  • How to create report image like artwork demo

    Dear Pakars
    How to create report image like artwork demo ?
    Thanks
    Imansyah

    Hello,
    Are you asking how to include images in a report? If so, take a look at the declarative blob support documentation -
    http://www.oracle.com/technology/obe/apex/apex31nf/apex31blob.htm
    Hope this helps,
    John.
    Blog: http://jes.blogs.shellprompt.net
    Work: http://www.apex-evangelists.com
    Author of Pro Application Express: http://tinyurl.com/3gu7cd
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone!

  • How to create Edit Image in my form

    hi All,
    I have a form with header and detail, in my detail block i need to add Edit Image in my form. When i click on this i should be able to open one of my text column.
    can any one please help me how to create new images....

    Siva,
    There is a different Technology Stack associated with the Enterprise Business Suite (EBS). amitphynyl is correct with the description of how to create a button with the edit.ico assigned to it, but with the EBS, you will want to speak to your DBA to get a list of all the Icons that are available as you will have more icons with the EBS than are available with a standard install of Forms Builder 6i. I would also suggest you ask your DBA to give you a copy of all the Icons so you can add them to your Forms Builder installation so they will be available to you during design of your Form.
    I would also recommend that you review the Oracle Applications User Interface Standards for Forms-Based Products guide in the Oracle Applications Documentation web site to ensure your Custom Form conforms to Oracle guidelines.
    Hope this helps,
    Craig B-)
    If someone's response is helpful or correct, please mark it accordingly.

  • How to create an image in an applikation

    very very very very simple question:
    how to create an image in an applikation!?thanks in advance!

    Image image=createImage(width,height)check out the IMAGE class in the API. as you said, this is simple stuff, thus you should be able to easily find the answer.

Maybe you are looking for

  • Why is the storage of apps on my mac book air so large?

    I have just downloaded Os x Yosemite on my mac book air, and when I checked my storage my app's section is very large. It says I have 43.33GB of apps, but when i check the amount of my apps in finder it only says I have about 10GB. One day i check it

  • Iphone 4s Organizing Photos for IPhoto

    Is there an app for iphone 4s that I could sort my photos on my phone and import them later into iphoto already sorted as they are in my phone? Basically Im looking to sort them in my phone as I take them instead of sift through hundreds of photos la

  • Problem with converting GF1 raw files

    I recently bought a Panasonic Lumix GF1 and use raw. However, my CS3 and Element 6.0 is not able to read the DNG files that I have created through Adobe DNG Converter. It doesn't seem to matter that I updated the Converter to 6.3. It creates DNG file

  • Advantages and disadvantages of SOAP over Http

    Hi! Can any one explain about advantages and disadvantages of SOAP over HTTP. Thanks Sreenath

  • Edit a mail message before sending

    How do I edit an email in Mail while spell-checking? Sounds simple, but my stupidity means I can't find out how to do it. Here's my scenario: I write a message, hit send and it brings up the spellchecker. Then while doing the spellcheck, I realise th