Help plz~ URGENT: Display image icon with specific coordinates

I want to view an ImageIcon with specific cooridnate (ie, I know the coordinate of the top left hand corner, and i know the height and the width of the "want to display part")
how can i make it such that it will onli view the part i want?
for example
i want to display say from (40, 40) (left hand corner) to (90,90) (right hand corner)
ImageIcon thePic= new ImageIcon("theimage.jpg");
ImageIcon newPic= new ImageIcon( XXXXXXXXX);
what should i put at the XXXXXXXXXX part?
Thanks in advance!

Use getSubImage method of BufferedImage. Something like:
Image originalImage = ImageIO.read(imageFile) ;// see ImageIO API
Image scaledImage = originalImage.getScaledInstance(40.40,90,90);
ImageIcon imageIcon = new ImageIcon(scaledImage);ImageIO.read is overloaded for files, inputStreams and URL's so you can choose how to load it.
I'll leave the rest to you
DB

Similar Messages

  • Since I restored my iPod, it displays an icon with an AC charger and an electrical outlet and there is no handling possible.

    Since I restored my iPod, it displays an icon with an adapter charger and an electrical outlet. So I connected with an AC charger as the demand for more than 48 hours but no change. My iPod no longer recognized in itunes or my computer and functions no longer work. I tried to reset it, Apple appears to leave room for a few seconds later the same icon with an electrical outlet and impossible to put it into disk mode. Help me please I don't know what to do. And forgive me my bad English I speak only French.

    Read the article that you linked

  • Displaying Images along with Drill Drown Results

    I'm using MS access 2003 as my data base and CF as the web
    language. I cannot find a topic in reference to displaying Images
    along with Drill down results. My tables in access have a OLE
    object included however I am clueless as how i can display the
    images with my drill down results. I just cannot find a link that
    talked about this issue already. Does anyone have a link to this
    forum topic?

    College Kid wrote:
    > I'm using MS access 2003 as my data base and CF as the
    web language. I cannot
    > find a topic in reference to displaying Images along
    with Drill down results.
    > My tables in access have a OLE object included however I
    am clueless as how i
    > can display the images with my drill down results. I
    just cannot find a link
    > that talked about this issue already. Does anyone have a
    link to this forum
    > topic?
    >
    Sorry, no link, but I think you want to be looking at the
    <cfimage...>
    and|or the <cfcontent...> tags. One or both of these
    tags should allow
    you to deliver the image from the database to the client.
    You are doing this in a bit of an unusual, but not unheard of
    way. Most
    people just store the image file in a handy directory
    accessible to the
    web server and then store the name|URL to this image as text
    in the
    database.
    But it is definitly possible to server up binary image data
    as well.
    Though I have never heard of this in conjunction with MS
    Access and 'OLE
    objects'. I usually hear this discussed in relation to more
    enterprise
    database management systems and BLOB [Binary Large OBjects]
    data fields.

  • URGENT HELP plz! crop image

    I have an image
    when loaded into my program, i have the getScaledInstance to about half of the size
    and then i want to crop on that scaled image icon, how can i do that?
    i tried the crop image filter, but it always need to getImage().getSource() which require the cooridnates of the original image (non scaled one)
    i do not have the cooridnate of the original image, i just have the scaled image coordinate part for cropping. How can i crop?

    Hey, here's some code:
              URL url = getClass().getClassLoader().getResource("some_image.jpg");
              Image rawImage = ImageIO.read(url);
              Image bufferedImage = new BufferedImage(X, X, BufferedImage.TYPE_INT_ARGB);
              // Perform your scaling here.
              bufferedImage.getGraphics().drawImage(rawImage, 0, 0, X, X, X);
              MediaTracker tracker = new MediaTracker(this);
              tracker.addImage(bufferedImage, 1);
              tracker.waitForID(1);
              Image cropImage = bufferedImage.getSubimage(X, X, X, X);Is this anymore useful to you?
    Warm regards.

  • Displaying images along with data on downloading from excel

    Hi All,
    I need to show images along with data in the excel sheet when user clicks downld to excel button.  Is there possible way to show the images in excel sheet if, kindly help.
    Thanks & Regards
    Jaspreet Kaur

    Hi Vinod
    Basically I have a report which needs to be downloaded to excel sheet. For each record there is a particular image in the first column for ex say my colums are img, desc.  Now image column contains an image corresponding to each description.  If its a file, a folder image is there; if its a document, a page image is there etc.  Now i am can display the data of  text fields  in the following manner ie label =new Label(0,RowCount, wdContext.nodeVn_PortalExcel().getVn_PortalExcelElementAt(i).getVa_Role(), PortalRoleDataFormat);
    PortalReportsheet.addCell(label);
    but how do i display the image in the excel sheet?
    Is it possible to do so, if so please provide assistance.
    Thanks & Regards
    Jaspreet Kaur

  • Unable to get Rmi program working. Help plz - urgent.

    Any help to get this problem resolved would be of help.
    I get the error as below:
    D:\test\nt>java Client
    Server
    Client exception: Error marshaling transport header; nested exception is:
    javax.net.ssl.SSLException: untrusted server cert chain
    java.rmi.MarshalException: Error marshaling transport header; nested exception is:
    javax.net.ssl.SSLException: untrusted server cert chain
    javax.net.ssl.SSLException: untrusted server cert chain
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.Handshaker.process_record([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a([DashoPro-V1.2-120198])
    at com.sun.net.ssl.internal.ssl.AppOutputStream.write([DashoPro-V1.2-120198])
    at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:76)
    at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:134)
    at java.io.DataOutputStream.flush(DataOutputStream.java:108)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:207)
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:178)
    at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:87)
    at Server_Stub.passArgs(Unknown Source)
    at Client.main(Client.java, Compiled Code)
    the server was invokde as:
    D:\test\nt>java -Djava.rmi.server.codebase="file:/d:/test" -Djava.policy=d:/test/policy Server a b c
    Server bound in registry
    where policy had allpermission
    The server program is given as below:
    import java.net.InetAddress;
    import java.rmi.Naming;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.rmi.RemoteException;
    import java.rmi.RMISecurityManager;
    import java.rmi.server.UnicastRemoteObject;
    public class Server extends UnicastRemoteObject implements Message
         private static String[] args;
         public Server() throws RemoteException
              // super();     
              super(0, new RMISSLClientSocketFactory(),
                   new RMISSLServerSocketFactory());
         public String[] passArgs() {
              System.out.println(args[0]);
              System.out.println(args[1]);
              System.out.println(args[2]);
              System.out.println(args.length);
              System.out.println();
              return args;
         public static void main(String a[])
              // Create and install a security manager
              if (System.getSecurityManager() == null)
                   System.setSecurityManager(new RMISecurityManager());
              args=a;
              try
                   Server obj = new Server();
                   // Bind this object instance to the name "Server"
                   Registry r = LocateRegistry.createRegistry(4646);
                   r.rebind("Server", obj);
                   System.out.println("Server bound in registry");
              } catch (Exception e) {
                   System.out.println("Server err: " + e.getMessage());
                   e.printStackTrace();
    The RMISSLServerSocketFactory class is as below:
    import java.io.*;
    import java.net.*;
    import java.rmi.server.*;
    import javax.net.ssl.*;
    import java.security.KeyStore;
    import javax.net.*;
    import javax.net.ssl.*;
    import javax.security.cert.X509Certificate;
    import com.sun.net.ssl.*;
    public class RMISSLServerSocketFactory implements RMIServerSocketFactory, Serializable
         public ServerSocket createServerSocket(int port)
              throws IOException     
              SSLServerSocketFactory ssf = null;
              try {
                   // set up key manager to do server authentication
                   SSLContext ctx;
                   KeyManagerFactory kmf;
                   KeyStore ks;
                   char[] passphrase = "passphrase".toCharArray();
                   ctx = SSLContext.getInstance("TLS");
                   kmf = KeyManagerFactory.getInstance("SunX509");
                   ks = KeyStore.getInstance("JKS");
                   ks.load(new FileInputStream("testkeys"), passphrase);
                   kmf.init(ks, passphrase);
                   ctx.init(kmf.getKeyManagers(), null, null);
                   ssf = ctx.getServerSocketFactory();
              } catch (Exception e)
                   e.printStackTrace();
                   return ssf.createServerSocket(port);
    The RMIClientSocketFactory is as below:
    import java.io.*;
    import java.net.*;
    import java.rmi.server.*;
    import javax.net.ssl.*;
    public class RMISSLClientSocketFactory     implements RMIClientSocketFactory, Serializable
         public Socket createSocket(String host, int port)
              throws IOException
              SSLSocketFactory factory =(SSLSocketFactory)SSLSocketFactory.getDefault();
              SSLSocket socket = (SSLSocket)factory.createSocket(host, port);
                   return socket;
    And finally the client program is :
    import java.net.InetAddress;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    import java.rmi.RemoteException;
    public class Client
         public static void main(String args[])
              try
                   // "obj" is the identifier that we'll use to refer
                   // to the remote object that implements the "Hello"
                   // interface
                   Message obj = null;
                   Registry r = LocateRegistry.getRegistry(InetAddress.getLocalHost().getHostName(),4646);
                   obj = (Message)r.lookup("Server");
                   String[] s = r.list();
                   for(int i = 0; i < s.length; i++)
                        System.out.println(s);
                   String[] arg = null;
                   System.out.println(obj.passArgs());
                   arg = obj.passArgs();
                   System.out.println(arg[0]+"\n"+arg[1]+"\n"+arg[2]+"\n");
              } catch (Exception e) {
                   System.out.println("Client exception: " + e.getMessage());
                   e.printStackTrace();
    The Message interface has the code:
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface Message extends Remote
         String[] passArgs() throws RemoteException;
    Plz. help. Urgent.
    Regards,
    LioneL

    hi Lionel,
    have u got the problem solved ?
    actually i need ur help regarding RMI - SSL
    do u have RMI - SSL prototype or sample codings,
    i want to know how to implement SSL in RMI
    looking for ur reply
    -shafeeq

  • Image Icon with JAR

    Hi,
    I would like to replace the standard coffee cup window icon with a custom image for a stand-alone Swing application, all packaged as a JAR file. As a quick test, I wrote the following:
    package me.swinginfo1;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    public class IconWindow extends JFrame {
         public IconWindow() {
              this.setSize(300, 200); //set the window size
              this.setLocationRelativeTo(null); //centers window on screen
              this.setTitle("Window with Icon"); //set the window title
              this.setDefaultCloseOperation(EXIT_ON_CLOSE); //end the program when window closed
              java.net.URL imageURL = this.getClass().getResource("images/red_circle.png");
              this.setIconImage(new ImageIcon(imageURL).getImage());
         * Executes Swing window... no arguments.
         public static void main(String[] args) {
              IconWindow myWindow = new IconWindow();
              myWindow.setVisible(true);
    When I run this class from the IDE (Eclipse, in this case), the program runs fine, and my icon image appears in the corner of the window as desired. However, when I package the program into a JAR, the JAR will not execute. My method of packaging is simply to use File -> Export -> JAR.
    Note: if I comment out the two lines related to the Icon Image, then the JAR executes as expected (but without my custom image icon, of course).
    I am concerned that perhaps the resource folder containing the image is not being included in the JAR. Is there an easy way to check this? Or is there something else I am doing wrong?
    Thanks!

    Thanks for the information atmguy. After checking the jar contents, I found that my resource files (the "red_circle.png" in this case) were not being packaged into the jar. It looks like the reason for this was that I had just added the directory to my project "src" directory by hand, rather than importing the files with Eclipse. Thus, when I packaged the jar using Eclipse, it was unaware of the resource files and therefore did not include them in the jar.
    Also, I found that in Windows a handy way of quickly viewing jar files is to rename the jar as a .zip, and then just explore the zip file. (As mentioned here: http://en.kioskea.net/faq/sujet-556-to-see-the-content-of-a-jar-file).
    The jar now executes as expected. Thanks!

  • Display an icon with pushbutton

    Hi all,
    i am using a simple pushbutton on the application bar , now i also want to display an icon on it.
    how can i achieve this?

    Hi,
    set the pf-status and then create the object.
    SET PF-STATUS 'ABC'.
    When you enter the GUI screen go to the application bar.
    later in the double click the text which you wrote in the application bar item you have an option
    Icon name
    check the icon you need through F4 help and select the necessary icon you want to display.
    regards
    sarves

  • Urgent: Displaying image in Abstract Portal Component.

    Hi all,
           In my application form, i am displaying a logo. I saved that logo under /dist/images. and in my form, i am giving the path as src = "/images/logo.jpg".  But image is not displaying. Can anyone quickly help me to solve this.

    Hi,
    U can't use the c:\foldernanme\image name as this is not permissible in portal.
    Therefore u need to use the following syntax :
    "/irj/portalapps/appl name/project name/folder name/image.jpg"
    e.g
    <img src="/irj/portalapps/com.tsl.portal.runtime.logon/layout/intro_logo.jpg" border="0">
    If the answer is helpful please reward with points.
    Thanks
    ritu

  • Urgent: Displaying image in JSPPAge in Abstract Portal Component.

    Hi all.
       In my application, i need to display the image in a table cell. My JSP page is under dist\portal-inf\jsp\ and my image is under dist\images\. I am calling the image from my page using
    <td>
    <image src = "..\..\images\image.jpg"></td>
    and i am trying with the absolute path also i.e., <src = "C:\Programfiles\....">
    But image is not displaying.
    Can anyone kindly helpme how to rectify this.

    Hi,
    Call it this way:
    src="/irj/portalapps/your par file name/project name>/images/image.jpg"
    You can't use the absolute path as the file is application is esecuted on the portal server, not from any local machine.
    Hope this helped. If it did, kindly consider rewarding points.
    Thanks and Regards,
    Prem
    SAP.
    Message was edited by:
            Prem Mascarenhas

  • My new iMac with Yosemite displays photo icons with a white border.  How can I remove this border?

    How can I remove the white border/'frame' around the photo icons, which I store in folders other than iPhoto?
    My computer is an iMac 27" (Late 2014 5K Retina display) with Yosemite 10.10.3.
    The border does not exist on any photos /images created on my MacbookPro (Lion) or any earlier computers.  It appears after importing to the iMac and only then after saving in either Preview or Photoshop Elements.
    I have looked in all "Preferences" but could not find how to remove the border.
    Any advice will be gratefully received.

    Thank you for the reply. I wanted to wait awhile in order to ensure that this corrected the issue. For a brief while, it did! However, it did not take long before the screen began once again hijacking my home button presses. This occurs even with Firefox removed from default applications ( triple-checked ).
    This never happened before version 35.

  • Displaying images is a specific layout

    Hi,
    It's me again. =)
    I'm trying to display an unknown number of images onto a ScrollPanel with a specific layout like for example. Every row can have just three images. And there are be an unknown number of rows depending how many images are to be loaded. How could i constraint the layout ?
    Cheers
    Crusca

    Use a new GridLayout(0, 3)

  • Please Help::How to display a Map with LIsts as Keys and Values using JSTL

    Hi,
    I need some assistance on how to display a Map in JSP using struts or core JSTL. I have a HashMap which has a List of keys and each key maps to a value of an ArrayList.i.e I have an ArrayList of taxCodes and each taxCode maps to a value of taxDetails which is an ArrayList of details for for that particular taxCode. I have some trouble to display each taxCode then display taxDetails for each taxCode. Here is my code below:
    OrderDetails.java
    package orderitems;
    import java.sql.*;
    import java.util.*;
    public class OrderDetails {
        private LineOder lineOrder;
        private Map lineItems;
        //returns an item number, key_item, from its unique keys
        public int getItemNumber(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            int itmNum = 0;
             * key_item a unique number for an item.
             * key_year,key_office,key_client,key_company unique keys
             * for each order where this key_item is taken
             * from.
            String select = "SELECT key_item FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + key_item +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                if(rst.next()){
                    itmNum = Integer.parseInt(rst.getString("key_item"));
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itmNum;
        //get a list of item number(item codes)
        public List getAllItemNumbers(String key_year,
                String key_office,String key_client,String key_company){
            List itemNumbers = new ArrayList();
            LineItem itemNumber = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            String select = "SELECT key_item FROM "+ Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    itemNumber = new LineItem();
                    itemNumber.setKey_item(Integer.parseInt(rst.getString("key_item")));
                    itemNumbers.add(itemNumber);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemNumbers;
        //get a list of tax codes
        public List getAllTaxCodes(int key_item, String key_year,
                String key_office,String key_client,String key_company){
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            ItemTax taxCode;
            List taxCodes = new ArrayList();
            int itemNum = getItemNumber(key_item, key_year,
                    key_office,key_client,key_company);
            String select = "SELECT key_tax_code FROM "+
                    Constants.WEB_TABLE +" WHERE key_item = " + itemNum +
                    " AND key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company +"'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    taxCode = new ItemTax();
                    taxCode.setKey_tax_code(rst.getString("key_tax_code"));
                    taxCodes.add(taxCode);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return taxCodes;
        /////This methode returns a Map which am trying to display in JSP
        //use tax code to get tax details
        public Map getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
                System.out.println();
                System.out.println("*********CONSOLE OUTPUT*************");//display on console
                Set set = itemTaxDetails.keySet();
                Iterator iter = set.iterator();
                System.out.println("Key\t\tValue\r\n");
                while (iter.hasNext()) {
                    Object taxCode=iter.next();
                    Object details=itemTaxDetails.get(taxCode);
                    System.out.println(taxCode +"\t" + details);
                System.out.println("************************************");
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return itemTaxDetails;
        //details of an item with all its taxes
        public List getAllItemDetails(String key_year,
                String key_office,String key_client,String key_company){
            List lineItems = new ArrayList();
            List itemNumbers = new ArrayList();
            Map taxDetails = new HashMap();
            LineItem item = null;
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //A list of all item numbers in the declaration
            itemNumbers = getAllItemNumbers(key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator itemIter= itemNumbers.iterator(); itemIter.hasNext();){
                    LineItem itemNum = (LineItem)itemIter.next();
                    int itemNumber = itemNum.getKey_item();
                    String select = "SELECT item_description,item_mass," +
                            "item_cost" +
                            " FROM " + Constants.WEB_TABLE +
                            " WHERE key_year = '"+key_year+"'" +
                            " AND key_office = '"+key_office+ "'"+
                            " AND key_client = '"+key_client+ "'"+
                            " AND key_company = '"+key_company+ "'"+
                            " AND key_item = " + itemNumber;
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        item = new LineItem();
                        item.setItem_description(rst.getString("item_description"));
                        item.setItem_mass(Float.parseFloat(rst.getString("item_mass")));
                        item.setKey_item(Integer.parseInt(rst.getString("item_cost")));
                        //////other details records ommited//////////////////////////
                        /* A HashMap of all itemTaxeCodes as its keys and an
                         * ArrayList of itemTaxedetails as its values
                        taxDetails = getItemTaxDetails(item.getKey_year(),item.getKey_office(),
                                item.getKey_client(),item.getKey_company(),item.getKey_item());
                        //item tax details
                        item.setItmTaxes(taxDetails);
                        //list of items with tax details
                        lineItems.add(item);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineItems;
        public Set getOrders(String key_year,String key_office,
                String key_client,String key_company){
            List lineItems = new ArrayList();
            Set lineOrders = new HashSet();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            LineOder lineOrder = null;
            String select = "SELECT * FROM " + Constants.WEB_TABLE +
                    " WHERE key_year = '" + key_year + "'" +
                    " AND key_office = '" + key_office + "'" +
                    " AND key_client = '" + key_client + "'" +
                    " AND key_company = '" + key_company + "'";
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                rst = stat.executeQuery(select);
                while(rst.next()){
                    lineOrder = new LineOder();
                    lineOrder.setKey_year(rst.getString("key_year"));
                    lineOrder.setKey_office(rst.getString("key_office"));
                    lineOrder.setKey_client(rst.getString("key_client"));
                    lineOrder.setKey_company(rst.getString("key_company"));
                    ////list of items with all their details
                    lineItems = getAllItemDetails(lineOrder.getKey_year(),lineOrder.getKey_office(),
                            lineOrder.getKey_client(),lineOrder.getKey_company());
                    //setting item details
                    lineOrder.setItems(lineItems);
                    //a list of order with all details
                    lineOrders.add(lineOrder);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            return lineOrders;
    Controller.java
    package orderitems;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Controller extends HttpServlet {
        private Map taxDetails = new HashMap();
        private OrderDetails orderDetails = null;
        protected void processRequest(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            String key_year = "2007";
            String key_office = "VZX00";
            String key_company = "DG20";
            String key_client =  "ZI001";
            int key_item = 1;
            String nextView = "/taxdetails_list.jsp";
            orderDetails = new OrderDetails();
            taxDetails = orderDetails.getItemTaxDetails(key_year,key_office,
                    key_company,key_client,key_item);
            //Store the collection objects into HTTP Request
            request.setAttribute("taxDetails", taxDetails);
            RequestDispatcher reqstDisp =
                    getServletContext().getRequestDispatcher(nextView);
            reqstDisp.forward(request,response);
        protected void doGet(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
        protected void doPost(HttpServletRequest request,
                HttpServletResponse response)throws
                ServletException, IOException {
            processRequest(request, response);
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <title>Simple Tax Detail Diaplay ::</title>
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <jsp:useBean id="taxDetails" class="java.util.HashMap" scope="request"/>
            <table>
                <c:forEach items="${taxDetails}" var="hMap">
                    <tr>
                        <td><c:out value="${hMap.key}" /></td>
                        <!--td><%--c:out value="${hMap.value}" /--%></td-->
                    </tr>
                </c:forEach>
            </table>
        </body>
    </html>am displaying taxCodes(in this case i have VAT and ICD) fine but cant figure out how to display a list of value for each taxCode.Here is the output am getting
    both in my JSP and on the console:
    *******************************CONSOLE OUTPUT****************************
    Key          Value
    ICD     [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    VAT [orderItems.ItemTax@13e6226, orderItems.ItemTax@9dca26]
    Edited by: aiEx on Oct 8, 2007 6:54 AM

    hi evnafets,
    yes i need a nested for loop.I have tried your advice but my bean properties are not found.Am getting this error:
    javax.servlet.ServletException: Unable to find a value for "key_item" in object of class "java.lang.String" using operator "."
    I have tried this as stated earlier in the post:I have tried to make the method getItemTaxDetails return a List and get the returned list value as taxDetails. I then tested to display this list on JSP and its displaying fine.
    public List getItemTaxDetails(String key_year,String key_office,
                String key_client,String key_company,int key_item){
            ItemTax taxDetail = null;
            List taxDetails = new ArrayList();
            List itemTaxCodes = new ArrayList();
            Map itemTaxDetails = new HashMap();
            Connection conn = null;
            Statement stat = null;
            ResultSet rst = null;
            //get a list of all tax codes of an item with a
            //given item number
            itemTaxCodes = getAllTaxCodes(key_item,key_year,
                    key_office,key_client,key_company);
            DbConnection dbConn = new DbConnection();
            try {
                conn = dbConn.getDbConnection(Constants.WEB_JNDI);
                stat = conn.createStatement();
                for(Iterator taxCodeIter= itemTaxCodes.iterator(); taxCodeIter.hasNext();){
                    ItemTax itemTaxCode = (ItemTax)taxCodeIter.next();
                    String taxCode = itemTaxCode.getKey_tax_code();
                    String select = "SELECT tax_type,tax_value," +
                            "tax_limit_val FROM "+ Constants.WEB_TABLE +
                            " WHERE key_item = "+ key_item +
                            " AND key_year = '" + key_year + "'" +
                            " AND key_office = '" + key_office + "'" +
                            " AND key_client = '" + key_client + "'" +
                            " AND key_company = '" + key_company +"'" +
                            " AND key_tax_code = '" + taxCode + "'";
                    rst = stat.executeQuery(select);
                    while(rst.next()){
                        taxDetail = new ItemTax();
                        //records to be displayed only
                        taxDetail.setKey_item(Integer.parseInt(rst.getString("key_item")));
                        taxDetail.setTax_value(rst.getString("tax_value"));
                        taxDetail.setTax_limit_val(Float.parseFloat(rst.getString("tax_limit_val")));
                        //////other details records ommited//////////////////////////
                        taxDetails.add(taxDetail);////An ArrayList of taxDetails for each taxCode
                     * A HashMap which has all taxCodes of an item as its keys
                     * and an ArrayList of taxdetails as its values.
                     * I return this for display in a JSP.
                    itemTaxDetails.put(taxCode,taxDetails);
            } catch (SQLException ex) {
                ex.printStackTrace();
            } finally{
                SQLHelper.cleanUp(rst, stat, conn);
            //return itemTaxDetails;
            return taxDetails;
        }And my JSP
    taxdetails_list.jsp
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!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">
            <link rel="stylesheet" type="text/css" href="imgs/orders.css"/>
        </head>
        <body>
            <table>
                <c:forEach var="curRecord" items="${taxDetails}" varStatus="rowCounter">
                        <c:choose>
                            <c:when test="${rowCounter.count % 2 == 0}">
                                <c:set var="rowStyle" scope="page" value="odd" />
                            </c:when>
                            <c:otherwise>
                                <c:set var="rowStyle" scope="page" value="even" />
                            </c:otherwise>
                        </c:choose>
                        <tr class="${rowStyle}">
                            <td>${curRecord.key_item}</td>
                            <td>${curRecord.tax_value}</td>
                            <td>${curRecord.tax_limit_val}</td>
                        </tr>
                    </c:forEach>
            </table>
        </body>
    </html>I can't see where am going wrong even with your advice.Please help.
    Thnx.

  • View display image BLOB with PHP!

    I using..
    $consulta = oci_parse($conexao,"select photo from userp where usrph_status = 'A' and id = :didbv");
    $didbv = $_POST["id"];
    oci_bind_by_name($consulta, ':didbv', $didbv);
    oci_execute($consulta, OCI_NO_AUTO_COMMIT);
    while (($row = oci_fetch_array($consulta, OCI_ASSOC)) != false) {
    $arr = oci_fetch_assoc($consulta);
    header("Content-type: image/JPEG");
    $result = $arr['PHOTO']->load();
    print "<img src='".$arr['PHOTO']."'>";
    print $result;
    echo $result;
    What appears in the result page is:
    This image contains errors and can not be displayed.
    How to fix this?

    - With that content type, you should be sending only binary data, not the HTML "<img" text.
    - You have both a print and and echo.
    Look at script 105 on p.236 of The Underground PHP and Oracle Manual | Homepage

  • ALV Help plz urgent

    Hi,
    Can anyone help me with ALV that how to display ALV Column Heading in Multiple Line.
    Means Multiple line Coulmn heading of ALV.
    Please fell free to contact me at
    [email protected]
    Regards,
    Muhammad Usman Malik
    SAP ABAP Consultant
    Siemens Pakistan
    +92-333-2700972

    Welcome to SDN.
    Copy Paste below code and execute the same. The output contains mutiple lines in header but I dont know how to do it in ALV. May be of some help to you.
    REPORT  ztestvib    MESSAGE-ID zz  LINE-SIZE 50.
    TYPE-POOLS: slis.
    DATA: x_fieldcat TYPE slis_fieldcat_alv,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          l_layout TYPE slis_layout_alv,
          x_events TYPE slis_alv_event,
          it_events TYPE slis_t_event.
    DATA: BEGIN OF itab OCCURS 0,
          vbeln LIKE vbak-vbeln,
          posnr LIKE vbap-posnr,
          male TYPE i,
          female TYPE i,
         END OF itab.
    SELECT vbeln
           posnr
           FROM vbap
           UP TO 20 ROWS
           INTO TABLE itab.
    x_fieldcat-fieldname = 'VBELN'.
    x_fieldcat-seltext_l = 'VBELN'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 1.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'POSNR'.
    x_fieldcat-seltext_l = 'POSNR'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 2.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'MALE'.
    x_fieldcat-seltext_l = 'MALE'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_fieldcat-fieldname = 'FEMALE'.
    x_fieldcat-seltext_l = 'FEMALE'.
    x_fieldcat-tabname = 'ITAB'.
    x_fieldcat-col_pos = 3.
    APPEND x_fieldcat TO it_fieldcat.
    CLEAR x_fieldcat.
    x_events-name = slis_ev_top_of_page.
    x_events-form = 'TOP_OF_PAGE'.
    APPEND x_events  TO it_events.
    CLEAR x_events .
    l_layout-no_colhead = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
      EXPORTING
        i_callback_program = sy-repid
        is_layout          = l_layout
        it_fieldcat        = it_fieldcat
        it_events          = it_events
      TABLES
        t_outtab           = itab
      EXCEPTIONS
        program_error      = 1
        OTHERS             = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    *&      Form  top_of_page
          text
    FORM top_of_page.
    *-To display the headers for main list
      FORMAT COLOR COL_HEADING.
      WRITE: / sy-uline(103).
      WRITE: /   sy-vline,
            (8) ' ' ,
                 sy-vline,
            (8)  ' ' ,
                 sy-vline,
            (19) '***'(015) CENTERED,
                 sy-vline.
      WRITE: /   sy-vline,
            (8) 'VBELN'(013) ,
                 sy-vline,
            (8) 'POSNR'(014) ,
                 sy-vline,
            (8) 'MALE'(016) ,
                 sy-vline,
             (8)  'FMALE'(017) ,
                 sy-vline.
      FORMAT COLOR OFF.
    ENDFORM.                    "top_of_page

Maybe you are looking for