Javax.Imageio Help Needed!

Basically, I found a site with a Javax.Imageio applet used to take screenshots with the click of a button.
The problem is that I know nothing about compiling Java, and I would like some assistance. This applet is a necessary addition to a webpage gaming site browser (Basically it's a framed page which goes to the different game's servers to play the game) so that the users can easily take screenshots of what's happening in the game.
The example script they have is located at:
http://schmidt.devlib.org/java/save-screenshot.html
But I need it to be compiled and changed a bit... The output only allows output of one file, which isn't good... It saves as out.png, and rewrites over it if you go to take a 2nd screenshot. The problem with this is that many users will need to take multiple screenshots. I need this example applet changed to do something like "screen1.png" then "screen2.png" then "screen3.png", and so on... If possible, I'd like it to save to Desktop/Screenshots/screen(x).png
Could I get a bit of assistance?
Thanks a lot, I appreciate any help I could get VERY much.
Please post the finished applet if you're able to help as a response to here, preferably in the format of a zip or rar with the files inside.

But I need it to be compiled and changed a bit... The output only allows output of one file, which isn't good...
It saves as out.png, and rewrites over it if you go to take a 2nd screenshot.
The problem with this is that many users will need to take multiple screenshots.
I need this example applet changed to do something like "screen1.png" then "screen2.png" then "screen3.png", and so on...
If possible, I'd like it to save to Desktop/Screenshots/screen(x).pngDid you even read the documentation on that web page, or the source code itself? From the statements you made, it would appear that you didn't read it very closely. If that directory already exists (Desktop/Screenshots), you don't have to change the code to save files as you want them (it won't auto-increment the number, though--auto-incrementing would require a change).
When you have downloaded and installed the Java SDK, re-read the web page, and give the program a shot.

Similar Messages

  • Help needed:Printing HTML file using javax.print

    Hi
    I am using the following code which i got form the forum for rpinting an HTML file.
    The folllowing code is working fine, but the problem is the content of HTML file is not getting printed. I am geeting a blank page with no content. What is the change that is required in the code? ALso is there any simpler way to implement this. Help needed ASAP.
    public boolean printHTMLFile(String filename) {
              try {
                   JEditorPane editorPane = new JEditorPane();
                   editorPane.setEditorKit(new HTMLEditorKit());
                   //editorPane.setContentType("text/html");
                   editorPane.setSize(500,500);
                   String text = getFileContents(filename);
                   if (text != null) {
                        editorPane.setText(text);                    
                   } else {
                        return false;
                   printEditorPane(editorPane);
                   return true;
              } catch (Exception tce) {
                   tce.printStackTrace();
              return false;
         public String getFileContents(String filename) {
              try {
                   File file = new File(filename);
                   BufferedReader br = new BufferedReader(new FileReader(file));
                   String line;
                   StringBuffer sb = new StringBuffer();
                   while ((line = br.readLine()) != null) {
                        sb.append(line);
                   br.close();
                   return sb.toString();
              } catch (Exception tce) {
                   tce.printStackTrace();
              return null;
         public void printEditorPane(JEditorPane editorPane) {
                   try {
                        HTMLPrinter htmlPrinter = new HTMLPrinter();
                        htmlPrinter.printJEditorPane(editorPane, htmlPrinter.showPrintDialog());
                   } catch (Exception tce) {
                        tce.printStackTrace();
         * Sets up to easily print HTML documents. It is not necessary to call any of the setter
         * methods as they all have default values, they are provided should you wish to change
         * any of the default values.
         public class HTMLPrinter {
         public int DEFAULT_DPI = 72;
         public float DEFAULT_PAGE_WIDTH_INCH = 8.5f;
         public float DEFAULT_PAGE_HEIGHT_INCH = 11f;
         int x = 100;
         int y = 80;
         GraphicsConfiguration gc;
         PrintService[] services;
         PrintService defaultService;
         DocFlavor flavor;
         PrintRequestAttributeSet attributes;
         Vector pjlListeners = new Vector();
         Vector pjalListeners = new Vector();
         Vector psalListeners = new Vector();
         public HTMLPrinter() {
              gc = null;
              attributes = new HashPrintRequestAttributeSet();
              flavor = null;
              defaultService = PrintServiceLookup.lookupDefaultPrintService();
              services = PrintServiceLookup.lookupPrintServices(flavor, attributes);
              // do something with the supported docflavors
              DocFlavor[] df = defaultService.getSupportedDocFlavors();
              for (int i = 0; i < df.length; i++)
              System.out.println(df.getMimeType() + " " + df[i].getRepresentationClassName());
              // if there is a default service, but no other services
              if (defaultService != null && (services == null || services.length == 0)) {
              services = new PrintService[1];
              services[0] = defaultService;
         * Set the GraphicsConfiguration to display the print dialog on.
         * @param gc a GraphicsConfiguration object
         public void setGraphicsConfiguration(GraphicsConfiguration gc) {
              this.gc = gc;
         public void setServices(PrintService[] services) {
              this.services = services;
         public void setDefaultService(PrintService service) {
              this.defaultService = service;
         public void setDocFlavor(DocFlavor flavor) {
              this.flavor = flavor;
         public void setPrintRequestAttributes(PrintRequestAttributeSet attributes) {
              this.attributes = attributes;
         public void setPrintDialogLocation(int x, int y) {
              this.x = x;
              this.y = y;
         public void addPrintJobListener(PrintJobListener pjl) {
              pjlListeners.addElement(pjl);
         public void removePrintJobListener(PrintJobListener pjl) {
              pjlListeners.removeElement(pjl);
         public void addPrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.addElement(psal);
         public void removePrintServiceAttributeListener(PrintServiceAttributeListener psal) {
              psalListeners.removeElement(psal);
         public boolean printJEditorPane(JEditorPane jep, PrintService ps) {
                   if (ps == null || jep == null) {
                        System.out.println("printJEditorPane: jep or ps is NULL, aborting...");
                        return false;
                   // get the root view of the preview pane
                   View rv = jep.getUI().getRootView(jep);
                   // get the size of the view (hopefully the total size of the page to be printed
                   int x = (int) rv.getPreferredSpan(View.X_AXIS);
                   int y = (int) rv.getPreferredSpan(View.Y_AXIS);
                   // find out if the print has been set to colour mode
                   DocPrintJob dpj = ps.createPrintJob();
                   PrintJobAttributeSet pjas = dpj.getAttributes();
                   // get the DPI and printable area of the page. use default values if not available
                   // use this to get the maximum number of pixels on the vertical axis
                   PrinterResolution pr = (PrinterResolution) pjas.get(PrinterResolution.class);
                   int dpi;
                   float pageX, pageY;
                   if (pr != null)
                        dpi = pr.getFeedResolution(PrinterResolution.DPI);
                   else
                        dpi = DEFAULT_DPI;
                   MediaPrintableArea mpa = (MediaPrintableArea) pjas.get(MediaPrintableArea.class);
                   if (mpa != null) {
                        pageX = mpa.getX(MediaPrintableArea.INCH);
                        pageY = mpa.getX(MediaPrintableArea.INCH);
                   } else {
                        pageX = DEFAULT_PAGE_WIDTH_INCH;
                        pageY = DEFAULT_PAGE_HEIGHT_INCH;
                   int pixelsPerPageY = (int) (dpi * pageY);
                   int pixelsPerPageX = (int) (dpi * pageX);
                   int minY = Math.max(pixelsPerPageY, y);
                   // make colour true if the user has selected colour, and the PrintService can support colour
                   boolean colour = pjas.containsValue(Chromaticity.COLOR);
                   colour = colour & (ps.getAttribute(ColorSupported.class) == ColorSupported.SUPPORTED);
                   // create a BufferedImage to draw on
                   int imgMode;
                   if (colour)
                        imgMode = BufferedImage.TYPE_3BYTE_BGR;
                   else
                        imgMode = BufferedImage.TYPE_BYTE_GRAY;
                   BufferedImage img = new BufferedImage(pixelsPerPageX, minY, imgMode);
                   Graphics myGraphics = img.getGraphics();
                   myGraphics.setClip(0, 0, pixelsPerPageX, minY);
                   myGraphics.setColor(Color.WHITE);
                   myGraphics.fillRect(0, 0, pixelsPerPageX, minY);
                        java.awt.Rectangle rectangle=new java.awt.Rectangle(0,0,pixelsPerPageX, minY);
                   // call rootView.paint( myGraphics, rect ) to paint the whole image on myGraphics
                   rv.paint(myGraphics, rectangle);
                   try {
                        // write the image as a JPEG to the ByteArray so it can be printed
                        Iterator writers = ImageIO.getImageWritersByFormatName("jpeg");
                        ImageWriter writer = (ImageWriter) writers.next();
                                       // mod: Added the iwparam to create the highest quality image possible
                        ImageWriteParam iwparam = writer.getDefaultWriteParam();
                        iwparam.setCompressionMode(ImageWriteParam.MODE_EXPLICIT) ;
                        iwparam.setCompressionQuality(1.0f); // highest quality
                        ByteArrayOutputStream out = new ByteArrayOutputStream();
                        ImageOutputStream ios = ImageIO.createImageOutputStream(out);
                        writer.setOutput(ios);
                        // get the number of pages we need to print this image
                        int imageHeight = img.getHeight();
                        int numberOfPages = (int) Math.ceil(minY / (double) pixelsPerPageY);
                        // print each page
                        for (int i = 0; i < numberOfPages; i++) {
                             int startY = i * pixelsPerPageY;
                             // get a subimage which is exactly the size of one page
                             BufferedImage subImg = img.getSubimage(0, startY, pixelsPerPageX, Math.min(y - startY, pixelsPerPageY));
                                                 // mod: different .write() method to use the iwparam parameter with highest quality compression
                             writer.write(null, new IIOImage(subImg, null, null), iwparam);
                             SimpleDoc sd = new SimpleDoc(out.toByteArray(), DocFlavor.BYTE_ARRAY.JPEG, null);
                             printDocument(sd, ps);
                             // reset the ByteArray so we can start the next page
                             out.reset();
                   } catch (PrintException e) {
                        System.out.println("Error printing document.");
                        e.printStackTrace();
                        return false;
                   } catch (IOException e) {
                        System.out.println("Error creating ImageOutputStream or writing to it.");
                        e.printStackTrace();
                        return false;
                   // uncomment this code and comment out the 'try-catch' block above
                   // to print to a JFrame instead of to the printer
                   /*          JFrame jf = new JFrame();
                             PaintableJPanel jp = new PaintableJPanel();
                             jp.setImage( img );
                             JScrollPane jsp = new JScrollPane( jp );
                             jf.getContentPane().add( jsp );
                             Insets i = jf.getInsets();
                             jf.setBounds( 0, 0, newX, y );
                             jf.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
                             jf.setVisible( true );*/
                   return true;
              * Print the document to the specified PrintService.
              * This method cannot tell if the printing was successful. You must register
              * a PrintJobListener
              * @return false if no PrintService is selected in the dialog, true otherwise
              public boolean printDocument(Doc doc, PrintService ps) throws PrintException {
                   if (ps == null)
                   return false;
                   addAllPrintServiceAttributeListeners(ps);
                   DocPrintJob dpj = ps.createPrintJob();
                   addAllPrintJobListeners(dpj);
                   dpj.print(doc, attributes);
                   return true;
              public PrintService showPrintDialog() {
                   return ServiceUI.printDialog(gc, x, y, services, defaultService, flavor, attributes);
              private void addAllPrintServiceAttributeListeners(PrintService ps) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < psalListeners.size(); i++) {
                   PrintServiceAttributeListener p = (PrintServiceAttributeListener) psalListeners.get(i);
                   ps.addPrintServiceAttributeListener(p);
              private void addAllPrintJobListeners(DocPrintJob dpj) {
                   // add all listeners that are currently added to this object
                   for (int i = 0; i < pjlListeners.size(); i++) {
                   PrintJobListener p = (PrintJobListener) pjlListeners.get(i);
                   dpj.addPrintJobListener(p);
              // uncomment this also to print to a JFrame instead of a printer
              /* protected class PaintableJPanel extends JPanel {
                   Image img;
                   protected PaintableJPanel() {
                        super();
                   public void setImage( Image i ) {
                        img = i;
                   public void paint( Graphics g ) {
                        g.drawImage( img, 0, 0, this );
    Thanks
    Ram

    Ram,
    I have had printing problems too a year and a half ago. I used all printing apis of java and I still find that it is something java lacks. Now basically you can try autosense. To check whether your printer is capable of printing the docflavor use this PrintServiceLookup.lookupPrintServices(flavor, aset); . If it lists the printer then he can print the document otherwise he can't. I guess that is why you get the error.
    Regards,
    Kevin

  • Help needed with image

    I currently need a web page to be turned to image, so that later i can paint boxes and regions for classifying the various part of the page. The problem is the page is dumped to a jpg but the program doesnt wait for the page to load and gives me a blank screen shot. below is the code
    JEditorPane jep = new JEditorPane();
    jep.setEditable(false);
    try {
    jep.setPage("http://www.google.com");
    catch (IOException e) {
    jep.setContentType("text/html");
    jep.setText("<html>Could not load Page </html>");
    JScrollPane scrollPane = new JScrollPane(jep);
    JFrame f = new JFrame("Displaying Web Page");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(scrollPane);
    f.setSize(512, 342);
    f.setVisible(true);
    Image image2 = scrollPane.createImage(800,600);
    BufferedImage image = (BufferedImage) image2;
    try {
    ImageIO.write(image, "jpg", new File("c:\\Temp\\tt.jpg"));
    } catch (IOException ex) {
    ex.printStackTrace();
    The image was turned to BufferedImage since it gave me errors when I tried to give write the image file.
    I think there needs to be some sort of wait operation but cannot figure out :\
    Any help would be greatly appreciated.
    Thanks in Advance
    Sceptre

    what do u mean by stack trace ?
    the problem is not the error with the image file, that is solved by using BufferedImage.
    The Problem is the program not waiting for the page to load before taking the screen shot.
    As for the error when using an Image for the ImageIO.write it was the following:
    symbol : method write(java.awt.Image,java.lang.String,java.io.File)
    location: class javax.imageio.ImageIO
    ImageIO.write(image2, "jpg", new File("c:\\Temp\\tt.jpg"));
    1 error
    Sorry if I wasn't clear

  • HELP NEED VERY URGENLTY!

    Hi everyone.
    I have written this program here in java and it has about 8 errors.
    Am not sure tho how to rectify the errors.
    Plis help me compile it and identify the errors.
    Thanx alot!
    ===============
    import java.lang.Object.*;
    import java.io.Reader.*;
    import java.io.InputStreamReader.*;
    import java.io.FileReader.*;
    import java.io.*;
    // Question 1:
    public class Image
    public static void main(String[] args)
         Image image = null;
    try {
    // Read from a file
    File file = new File("c:/hello.jpeg");
    image = ImageIO.read(file);
    // Read from an input stream
    InputStream is = new BufferedInputStream(
    new FileInputStream("c:/hello.jpeg"));
    image = ImageIO.read(is);
    // Read from a URL
    // URL url = new URL("http://yahoo.com/image.gif");
    //image = ImageIO.read(url);
    } catch (IOException e) {
    //Question 2:
    // Use a label to display the image
    JFrame frame = new JFrame();
    JLabel label = new JLabel(new ImageIcon(image));
    frame.getContentPane().add(label, BorderLayout.CENTER);
    frame.pack();
    frame.setVisible(true);
    }

    The corrected code is:
    import java.lang.Object.*;
    import java.io.Reader.*;
    import java.io.InputStreamReader.*;
    import java.io.FileReader.*;
    import java.io.*;
    // added to use the ImageIO class
    //import javax.imageio.ImageIO;
    // Question 1:
    public class Image
         public static void main(String[] args){
         Image image = null;
              try {
                   // Read from a file
                   File file = new File("c:/hello.jpeg");
              //     image = ImageIO.read(file);
                   // Read from an input stream
                   InputStream is = new BufferedInputStream(
                   new FileInputStream("c:/hello.jpeg"));
              //     image = ImageIO.read(is);
                   // Read from a URL
                   // URL url = new URL("http://yahoo.com/image.gif");
                   //image = ImageIO.read(url);
              } catch (IOException e) {}
         } // end main()
    }// end class
    I have commented two lines ImageIO.read(); as you need to import the package "javax.imageio.ImageIO" to use this.
    Also set the jar file (containing the package) in the class file.

  • Help needed on CD740 ???

    Help needed on CD740 ? My CD740 is GREAT , well , it was great !!? The sound and general performance are wonderful , but , it now has a fault !!? Shock Horror !!
    What can it be ?!!? Well , the display illumination has failed , as in , there isn't any !!? Have to use a torch to read it !!? Not good. Now , here's the thing , I want a phone number (UK zone) ?to talk to an actual human and I cannot find one !!? That is soooooo annoying !!? The unit is out of warranty so I want to repair this myself , no worries , I once worked for Philips in their pro studio equipment repair workshop so I know my way around black boxes !! I would like a service manual though so that I can get the case apart without damage. So , can anyone help me with a phone number , pretty please ?!!
    Thanx.

    I tried compling servlet, but it is raising error
    that coul not find package javax.servletWhat I did not mention... you need to add those JARs in the Classpath explicitly. You will find them in %TOMCAT_HOME%\common\lib. You atleast need to add servlet-api.jar to your Classpath. :)

  • Help needed to loadjava apache poi jars into oracle database.

    Help needed to loadjava apache poi jars into oracle database. Many classes left unresolved. (Poi 3.7, database 11.1.0.7). Please share your experience!

    Hi,
    The first 3 steps are just perfect.
    But with
    loadjava.bat -user=user/pw@connstr -force -resolve geronimo-stax-api_1.0_spec-1.0.jar
    the results are rather unexpected. Here is a part of the log file:
    arguments: '-user' 'ccc/***@bisera7-db.dev.srv' '-fileout' 'c:\temp\load4.log' '-force' '-resolve' '-jarsasdbobjects' '-v' 'geronimo-stax-api_1.0_spec-1.0.jar'
    The following operations failed
    resource META-INF/MANIFEST.MF: creation (createFailed)
    class javax/xml/stream/EventFilter: resolution
    class javax/xml/stream/events/Attribute: resolution
    class javax/xml/stream/events/Characters: resolution
    class javax/xml/stream/events/Comment: resolution
    class javax/xml/stream/events/DTD: resolution
    class javax/xml/stream/events/EndDocument: resolution
    class javax/xml/stream/events/EndElement: resolution
    class javax/xml/stream/events/EntityDeclaration: resolution
    class javax/xml/stream/events/EntityReference: resolution
    class javax/xml/stream/events/Namespace: resolution
    class javax/xml/stream/events/NotationDeclaration: resolution
    class javax/xml/stream/events/ProcessingInstruction: resolution
    class javax/xml/stream/events/StartDocument: resolution
    class javax/xml/stream/events/StartElement: resolution
    class javax/xml/stream/events/XMLEvent: resolution
    class javax/xml/stream/StreamFilter: resolution
    class javax/xml/stream/util/EventReaderDelegate: resolution
    class javax/xml/stream/util/StreamReaderDelegate: resolution
    class javax/xml/stream/util/XMLEventAllocator: resolution
    class javax/xml/stream/util/XMLEventConsumer: resolution
    class javax/xml/stream/XMLEventFactory: resolution
    class javax/xml/stream/XMLEventReader: resolution
    class javax/xml/stream/XMLEventWriter: resolution
    class javax/xml/stream/XMLInputFactory: resolution
    class javax/xml/stream/XMLOutputFactory: resolution
    class javax/xml/stream/XMLStreamReader: resolution
    resource META-INF/LICENSE.txt: creation (createFailed)
    resource META-INF/NOTICE.txt: creation (createFailed)
    It seems to me that the root of the problem is the error:
    ORA-29521: referenced name javax/xml/namespace/QName could not be found
    This class exists in the SYS schema though and is valid. If SYS should be included as a resolver? How to solve this problem?

  • Help needed on Servlets and JSTL

    Hi
    I am using tomcat 5.5 and JDK 1.5. What are the softwares I have to download for compiling servlets and creating JSTL ?. Help needed.
    Thanks
    IndyaRaja

    I tried compling servlet, but it is raising error
    that coul not find package javax.servletWhat I did not mention... you need to add those JARs in the Classpath explicitly. You will find them in %TOMCAT_HOME%\common\lib. You atleast need to add servlet-api.jar to your Classpath. :)

  • Help needed to run JSTL 1.1 in Tomcat 6.0.16

    Hi All,Help needed to run JSTL 1.1 in Tomcat 6.0.16. I am trying to run the example given in http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html The example tries to connect to MySQL database from JSP using JSTL and JNDI Datasource.I am running the example using Eclipse 3.4.2 using Sysdeo plugin to start and stop Tomcat server from Eclipse IDE.
    My web.xml file has <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    </web-app>
    and test.jsp has proper taglib directives
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    I have placed the jstl.jar and standard.jarof the jakarta-taglibs-standard-1.1.2.zip under E:\Deepa\workspace\DBTest\WebContent\WEB-INF\lib directory also placedcontext.xml file under E:\Deepa\workspace\DBTest\WebContent\META-INF and the content of context.xml is as below
    <Context path="/DBTest" docBase="DBTest"
    debug="5" reloadable="true" crossContext="true">
    <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource"
    maxActive="100" maxIdle="30" maxWait="10000"
    username="deepa" password="mysql" driverClassName="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
    </Context>
    Now while running the example, Eclipse creates one DBTest.xml file under C:\Program Files\Apache Software Foundation\Tomcat 6.0\conf\Catalina\localhost
    which has the following line:
    <Context path="/DBTest" reloadable="true" docBase="E:\Deepa\workspace\DBTest" workDir="E:\Deepa\workspace\DBTest\work" />
    I am getting the following error when running http://localhost/DBTest/WebContent/test.jsp
    in Browser:
    <HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/sql cannot be resolved in either web.xml or the jar files deployed with this application
    org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
    org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
    org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
    org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
    org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
    org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:431)
    org.apache.jasper.compiler.Parser.parseDirective(Parser.java:494)
    org.apache.jasper.compiler.Parser.parseElements(Parser.java:1444)
    org.apache.jasper.compiler.Parser.parse(Parser.java:138)
    org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
    org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:154)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:315)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    In the Tomcat Server console, I am getting the following error:
    INFO: Server startup in 7295 ms
    May 20, 2009 6:36:48 AM org.apache.jasper.compiler.TldLocationsCache processWebDotXml
    WARNING: Internal Error: File /WEB-INF/web.xml not found
    May 20, 2009 6:36:48 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/sql cannot be resolved in either web.xml or the jar files deployed with this application
    what is the problem with my code?
    When running the same example, by creating a local server in Eclipse(creating new Server connection pointing to same Tomcat 6.0 installation) it runs fine without any error.

    Hi evnafets,
    Wow, very helpful information, great insight into working of Eclipse. Thanks a lot.
    I have one more question. I have a context.xml file under {color:#0000ff}E:\Deepa\workspace\DBTest\WebContent\META-INF{color} folder and that has the Resource element to connect to MySQL database:
    {code{color:#000000}}{color}<Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true">
    <Resource name="jdbc/TestDB" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="deepa" password="mysql" driverClassName="com.mysql.jdbc.Driver"
    {color:#0000ff}url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>{color}
    {color:#0000ff}</Context>{color}As usual when running application in local Tomcat server of Eclipse, this data source works fine. But when I run the application on Tomcat, by starting Sysdeo plugin from Eclipse, the DBTest.xml file created in C:\Tomcat 6.0\conf\Catalina\localhost has the context entry as<Context path="/DBTest" reloadable="true" docBase="E:\Deepa\workspace\DBTest\WebContent" workDir="E:\Deepa\workspace\DBTest\work">
    </Context>The<Resource> element I have specified in the context.xml of \WebContent\META-INF folder is not taken into account by Tomcat and it gives the following error:May 21, 2009 5:20:04 AM org.apache.catalina.core.StandardWrapperValve invoke
    SEVERE: Servlet.service() for servlet jsp threw exception
    javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException_: Cannot create JDBC driver of class '' for connect URL 'null'"
    _at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(_QueryTagSupport.java:276_)
    at org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(_QueryTagSupport.java:159_)
    at org.apache.jsp.test_jsp._jspx_meth_sql_005fquery_005f0(_test_jsp.java:113_)
    at org.apache.jsp.test_jsp._jspService(_test_jsp.java:66_)
    at org.apache.jasper.runtime.HttpJspBase.service(_HttpJspBase.java:70_)
    at javax.servlet.http.HttpServlet.service(_HttpServlet.java:717_)
    at org.apache.jasper.servlet.JspServletWrapper.service(_JspServletWrapper.java:374_)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(_JspServlet.java:342_)
    at org.apache.jasper.servlet.JspServlet.service(_JspServlet.java:267_)
    at javax.servlet.http.HttpServlet.service(_HttpServlet.java:717_)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(_ApplicationFilterChain.java:290_)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(_ApplicationFilterChain.java:206_)
    at org.apache.catalina.core.StandardWrapperValve.invoke(_StandardWrapperValve.java:233_)
    at org.apache.catalina.core.StandardContextValve.invoke(_StandardContextValve.java:191_)
    at org.apache.catalina.core.StandardHostValve.invoke(_StandardHostValve.java:128_)
    at org.apache.catalina.valves.ErrorReportValve.invoke(_ErrorReportValve.java:102_)
    at org.apache.catalina.core.StandardEngineValve.invoke(_StandardEngineValve.java:109_)
    at org.apache.catalina.connector.CoyoteAdapter.service(_CoyoteAdapter.java:286_)
    at org.apache.coyote.http11.Http11Processor.process(_Http11Processor.java:845_)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(_Http11Protocol.java:583_)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(_JIoEndpoint.java:447_)
    at java.lang.Thread.run(_Thread.java:619_)
    {code}
    So to overcome this error I had to place the <Resource> element in DBTest.xml under C:\Tomcat 6.0\conf\Catalina\localhost {color:#000000}and then it works fine. {color}{color:#ff0000}*Why is the context.xml file in META-INF not considered by Tomcat server using Sysdeo Plugin?*
    *Thanks,*
    *Deepa*{color}
    {color}
    Edited by: Deepa76 on May 26, 2009 9:32 PM

  • Exception in thread "main" javax.naming.NoInitialContextException: Need to

    Hey,
    I am exploring the technique 'JMS'. I found an sample code on the Internet (https://www.redhat.gl/docs/manuals/jboss/jboss-eap-4.2/doc/Server_Configuration_Guide/JMS_Examples-A_Point_To_Point_Example.html).
    But unfortunately, by running the code on my local computer, I got an NoInitialContextException (Exception in thread "main" javax.naming.NoInitialContextException: Need to ...Application resource file: java.naming.factory.initial). After searching on the Internet, I discovered I need to configure some JNDI values. But, also after passing on the variables to the class by parameter (-Djava.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory), I still get the same error.
    What have I forgotten? Hope someone can help. Thanks!
    Tongue78.
    public void setupPTP()
    throws JMSException,
    NamingException
    InitialContext iniCtx = new InitialContext();
    Object tmp = iniCtx.lookup("ConnectionFactory"); // exception occurs here..
    QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
    conn = qcf.createQueueConnection();
    que = (Queue) iniCtx.lookup("queue/testQueue");
    session = conn.createQueueSession(false,
    QueueSession.AUTO_ACKNOWLEDGE);
    conn.start();
    ....

    Refer to the Sun App Server documentation.
    http://docs.sun.com/source/819-0079/dgacc.htmlIt lists down the steps you need to follow.

  • Javax.imageio.ImageIO

    Hello,
    I have recently installed Fedora Core 2 to a dell dimension 8100 and I am trying to compile the program and get this error each time javac runs. error:
    Class or interface `javax.imageio.ImageIO' not found in import.
    import javax.imageio.ImageIO;
    ^
    Is linux installed with an sdk native to the system? If so how do I uninstall it? Would it conflict if I installed another Java SDK I found that the package jdk 1.5.0_05fcs was installed so I did a rpm -e command on it and reinstalled a fresh copy but this did not help. Thanks!-signol

    Ok, I got this error
    gcj: unrecognized option `-version'
    gcj: no input files
    I originally put j2sdk 1.4.2_09 on thinking there was no java to begin with, could this cause some of the errors? Also how would i go about uninstalling the package?-Signol

  • Using javax.imageio in JSP

    Hi
    I have a simple code snippet that I use to read in JPG/GIF image from a file and create a new image that is upside down . Here is my snippet.
    //create upside down image
    try { 
    String imgPath = "\\images\\AINCC.gif";
    File fImg = new File(imgPath);
    BufferedImage imgREG = ImageIO.read(fImg);
    int iW = imgREG.getWidth(null);
    int iH = imgREG.getHeight(null);
    // Flip the image vertically and horizontally (equivalent to rotating the image 180 degrees)
    AffineTransform tx = AffineTransform.getScaleInstance(-1.0,-1.0);
    tx.translate(-iW, -iH);
    //tx.scale(0.8,0.8);
    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    BufferedImage imgUSD = op.filter(imgREG, null);
    // write flipped image to a file
    File fUSD = new File("images\\USD_image.tmp");
    ImageIO.write(imgUSD,"jpg",fUSD);
    catch (Exception e) {
    e.printStackTrace();
    If I use this in a stand alone Java app it works fine but it will not work from the JSP page....
    I have updated my server.policy file to give /images directory read, write, delete priviledges and I tried all the variations of the path (relative, absolute, direct....)...
    I get the following error from the server log:
    [#|2004-05-17T13:47:56.173-0400|WARNING|sun-appserver-pe8.0|javax.enterprise.system.stream.err|_ThreadID=11;|
    javax.imageio.IIOException: Can't read input file!
    at javax.imageio.ImageIO.read(ImageIO.java:1263)
    at org.apache.jsp.ecards.mailcard_jsp._jspService(mailcard_jsp.java:125)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:141)
    Can someone tell me what am I missing....
    My JSP page is mailcard.jsp and images are under it in the images subdirectory....
    Thanks
    Amir

    Hi,
    Replace the following lines:
    try{
    String imgPath = "\\images\\AINCC.gif";
    with
    <%String contextPath = request.getContextPath();%>
    try{
    String imgPath = <%=contextPath%> + "\\images\\AINCC.gif";
    You may also need to set the web application context root.
    Regards,
    bazooka.

  • ImageIO - javax.imageio.IIOException: Can't get input stream from URL

    Hi,
    I'm developing a program which accesses a given URL of an image and saves it to a file. However when I try this I get the following error:
    javax.imageio.IIOException: Can't get input stream from URL!
         at javax.imageio.ImageIO.read(Unknown Source)
         at ImageSave.main(ImageSave.java:12)
    Caused by: java.net.ConnectException: Connection timed out: connect
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(Unknown Source)
         at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
         at java.net.PlainSocketImpl.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at java.net.Socket.connect(Unknown Source)
         at sun.net.NetworkClient.doConnect(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.openServer(Unknown Source)
         at sun.net.www.http.HttpClient.<init>(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.http.HttpClient.New(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
         at java.net.URL.openStream(Unknown Source)
         ... 2 moreThe internet connection I am using uses a proxy server and I think this is where the problem lies. I'm using Eclipse version 3.3 and I've tried changing the network settings to use the proxy's hostname and port but this still isn't working. I've also tried using System.setProperty("http.proxyHost", "hostname") and System.setProperty("http.proxyPort", "port") but that hasn't worked for me either. Below is my class in full.
    import java.awt.image.*;
    import javax.imageio.*;
    import java.io.*;
    import java.net.*;
    public class ImageSave
         public static void main(String args[])
              try {
                   URL url = new URL("http://www.example.com/image.jpg");
                   BufferedImage image = ImageIO.read(url);
                   ImageIO.write(image, "JPG", new File("image.jpg"));
              catch (Exception e) {
                   e.printStackTrace();
    }The error occurs with the line: BufferedImage image = ImageIO.read(url);
    I have tried looking for a way to change how this specific method accesses the internet (e.g: a Proxy parameter with URLConnection) but there doesn't seem to be any.
    Any help or suggestions would be greatly appreciated.
    -Robert

    Ah, that worked fine. I had thought of using that earlier but I was under the impression that the input stream would be HTML rather than an actual image. Not sure why.. Anyway, thanks very much for your help!
    Here is the new code with your suggested revisions and a URLConnection to get the input stream:
    import java.awt.image.*;
    import javax.imageio.*;
    import java.io.*;
    import java.net.*;
    public class ImageSave
        public static void main(String args[])
            try {
                 // This is where you'd define the proxy's host name and port.
                 SocketAddress address = new InetSocketAddress(hostName, port);
                 // Create an HTTP Proxy using the above SocketAddress.
                 Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
                 URL url = new URL("www.example.com/image.jpg");
                 // Open a connection to the URL using the proxy information.
                 URLConnection conn = url.openConnection(proxy);
                 InputStream inStream = conn.getInputStream();
                 // BufferedImage image = ImageIO.read(url);
                 // Use the InputStream flavor of ImageIO.read() instead.
                 BufferedImage image = ImageIO.read(inStream);
                 ImageIO.write(image, "JPG", new File("image.jpg"));
            catch (Exception e) {
                 e.printStackTrace();
    }Edited by: Ragnarob on Apr 21, 2009 2:49 AM

  • Adding JTable on an image..............??help need.....edited

    i am using JFame
    on JFrame i hav added JTabbedpane....
    on one of the tab i hav added image on whole background....
    on that tab i hav added JTable....
    but when i add JTable on that tab .....instead of adding table on that image...it add image on background with no image
    that no color part shoud be covered with part of image added on a tab
    and also i want to position (x,y) of JTable on tab.....
    so i hav used gridLayout so that it looks better....but that not i want.....
    here is the code.... check search tab
    //project.java
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f,pass;
    JTabbedPane jtp = new JTabbedPane();
    JApplet obj=new JApplet();
    JMenuBar mb=new JMenuBar();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    JMenu m1=new JMenu("File");
    JMenu m2=new JMenu("About");
    JMenu m3=new JMenu("Help");
    mb.add(m1);
    mb.add(m2);
    mb.add(m3);
    JMenuItem mi1=new JMenuItem("Save");
    JMenuItem mi2=new JMenuItem("Exit");
    JMenuItem mi3=new JMenuItem("save as");
    mi3.setVisible(true);
    m1.add(mi1);
    m1.add(mi3);
    m1.add(mi2);
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(mb);
    f.setJMenuBar(mb);
    f.add(jtp);
    f.setSize(500,600);
    f.setVisible(true);
    public class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    public searchpanel(){
    Icon icon = new ImageIcon("Sunset.jpg");
    JLabel label = new JLabel(icon);
    add(label);
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    // Create the table
    JTable table = new JTable(data, colHeads);
    JTableHeader header = table.getTableHeader();
    table.setRowHeight(20);
    TableColumn column = table.getColumnModel().getColumn(0);
    table.setCellSelectionEnabled(true);
    table.getTableHeader().setPreferredSize(new Dimension(0,30));
    table.setFont(new Font("Dialog", Font.BOLD, 15));
    table.setBackground(Color.green);
    header.setFont(new Font("Courier",Font.BOLD,25));
    header.setBackground(Color.yellow);
    //label.add(table,BorderLayout.CENTER);
    // Add table to a scroll pane
    int v = ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
    int h = ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED;
    JScrollPane jsp = new JScrollPane(table, v, h);
    // Add scroll pane to the content pane
    this.add(jsp, BorderLayout.SOUTH);
    add image i ur system....make changes on searchpanel class
    thanks in advance...

    on one of the tab i hav added image on whole background....no you haven't - you've added a JLabel to a GridLayout JPanel
    I have no idea what you're really trying to do, but here's a tab with image background and transparent table (except for the header)
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    class tdsgui{
    JFrame f;
    JTabbedPane jtp = new JTabbedPane();
    public tdsgui(){
    f=new JFrame("TELEPHONE DIRECTORY SYSTEM");
    public void launch(){
    jtp.addTab(" REGISTRATION ",new registerpanel());
    jtp.addTab(" MODIFY ",new updatepanel());
    jtp.addTab(" SEARCH ", new searchpanel());
    f.add(jtp);
    f.setSize(500,600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setVisible(true);
    class project{
    public static void main(String args[]){
    tdsgui next=new tdsgui();
    next.launch();
    class registerpanel extends JPanel{
    public registerpanel(){
    class updatepanel extends JPanel{
    public updatepanel(){
    class searchpanel extends JPanel{
    Image img;
    public searchpanel(){
    try{img = javax.imageio.ImageIO.read(new java.net.URL(getClass().getResource("Test.gif"), "Test.gif"));}
    catch(Exception e){}//do nothing - handled in paintComponent
    this.setLayout(new GridLayout(2,0));
    final String[] colHeads = { "Name", "Phone", "Fax" };
    final String[][] data = {
    { "Gail", "4567", "8675" },
    { "Ken", "7566", "5555" },
    { "Viviane", "5634", "5887" },
    { "Melanie", "7345", "9222" },
    { "Anne", "1237", "3333" },
    { "John", "5656", "3144" }
    JTable table = new JTable(data, colHeads);
    table.setOpaque(false);
    table.setBackground(new Color(0,0,0,0));
    JScrollPane jsp = new JScrollPane(table);
    jsp.setOpaque(false);
    jsp.getViewport().setOpaque(false);
    this.add(jsp);
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    if(img != null) g.drawImage(img,0,0,this.getWidth(), this.getHeight(),this);
    }

  • Problems with javax.imageio.ImageIO (cannot be resolved) *Urgent*

    I was trying to import javax.imageio.ImageIO into my project but it cannot work... I am using Websphere Application 5.1.2 and using JDK 1.4.2_07... I try to import external jar containing javax.image but it still can't solve my problem... So can anyone help me... Thank alot...

    There is no exception, the javax.imageio.ImageIO.read(InputStream input) method simply returns null, indicating that the stream can't be decoded with any of the registered ImageReaders.
    BufferedImage bi = javax.imageio.ImageIO.read(new ByteArrayInputStream(wr2.getData()))
    wr2 is of a class that I have written myself, and the method getData() returns a byte[] array consisting of the bytes previously read from the .gif-file...
    there is nothing wrong with the data stored in the byte[] array, I have even compared it to the original file byte by byte... and it's all the same.
    this works though:
    BufferedImage bi = javax.imageio.ImageIO.read(new FileInputStream("img/iconOnlineDark.gif"))
    Strange problem, in my opinion... but I'm not an expert in streams... so it might not be as strange as it seems to me...? Anyway, I must find a solution to this.
    /erik

  • JCmboBox setSelectedIndex help needed !!!!!!!!!!!!

    hi,
    I hope it's a trivial question but I am not able to solve it so need your help plz. I have a demo program if you run it you will see what I mean. Actually I am adding items to my JComboBox dynamically. My problem is that if I add the items with the same name and then explicitly set them selected my first item with same name is always highlighted and selected even though I say to select the last item which I add. But when I pull down the comboBox my first item with the same name is selected and highlighted not the last one. Please run the program and see. How can I solve this problem help needed.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ComboBoxDemo extends JPanel {
    JButton picture;
    public ComboBoxDemo() {
    String[] petStrings = { "Bird", "Cat", "Dog", "Rabbit", "Pig" };
    // Create the combo box, select the pig
    final JComboBox petList = new JComboBox(petStrings);
    picture = new JButton("ADD");
    picture.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    petList.addItem("TEST ");
                   int nodeTotal =     petList.getItemCount();
                   petList.setSelectedIndex(nodeTotal-1);
    setLayout(new BorderLayout());
    add(petList, BorderLayout.NORTH);
    add(picture, BorderLayout.SOUTH);
    setBorder(BorderFactory.createEmptyBorder(20,20,20,20));
    public static void main(String s[]) {
    JFrame frame = new JFrame("ComboBoxDemo");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    frame.setContentPane(new ComboBoxDemo());
    frame.pack();
    frame.setVisible(true);
    I want to select the last item I add even if there exists an item with same name.
    Any help is greatly appreciated.
    Thanks.

    never mind I got the answer.
    Tnaks

Maybe you are looking for

  • Newbie UPDATE request.

    Hello everyone. I'm trying to move a whole bunch of data from Table1 to Table2, using the UPDATE function, but only under special circumstances. I wish to move all available addressId's from Table1 to Table2, but only if there isn't an addressId in T

  • Report font in linux

    Hello! I use Courier font for my report (in Hebrew). I design the report on windows and then deploy it on linux. When i run the report i do see the text in my fields, but in titles i see ??? instead of the text. What can be a problem?

  • Length Of Query Description

    Can Any One Suggest Me How To Maximize Query Description Length i.e More than 120 Char . Regards Supraja.K

  • Refresh Normal ALV

    Hi everybody, I have done normal ALV report.I did not use any methods for displaying . now i want to refresh the normal ALV report. is there any command for refreshing the alv report.... thanks and regards, varahagiri.

  • Why was my recent call list deleted without my knowledge

    Why was my recent call list deleted without my knowledge?