How to writing an image from my applet to my apache webserver

hi everyone,
i have a big problem, writing an image from my applet to my apache
webserver. i tried three way's of writing that file. every way was
described in forums to solve this problem, but non of them worked and
i don't know why. i'll give you the code of my writing-methods and
describe, what happen when i test them, in order someone of you can
give me an usefull tip, where the problem is.
as inputparameter i give my method a new URL referring to
http://localhost/test.jpg (this is the same directory, where my applet
is loaded from, so i should have reading and writing permission,
havn't i? while i'm developing, my applet runs on the same pc as my
webserver, just in case you're wondering about localhost) and a
selfmade BufferedImage (i already testet if it is not null and shows
the correct things ... all ok).
1. try:
private void writeImageToServer(URL fileURL,BufferedImage img){
try {
URLConnection urlConnection = fileURL.openConnection();
urlConnection.setDoOutput(true);
OutputStream urlout = urlConnection.getOutputStream();
BufferedOutputStream out = new BufferedOutputStream(urlout);
ImageIO.write(img,"jpg",out);
out.close(); // i also tried without this line -> same result
// additionally a question: do i need
out.close()?
catch( IOException e ){
e.printStackTrace();
result:
test.jpg doesn't appear in the webroot. but some very strange messages
in the error.log of my apacheserver:
[Tue Jun 08 11:40:22 2004] [error] [client 127.0.0.1] File does not
exist: c:/programme/apache
group/apache/htdocs/meta-inf/services/javax.imageio.spi.ImageOutputStreamSpi
[Tue Jun 08 11:40:22 2004] [error] [client 127.0.0.1] File does not
exist: c:/programme/apache
group/apache/htdocs/meta-inf/services/javax.imageio.spi.ImageReaderSpi
[Tue Jun 08 11:40:22 2004] [error] [client 127.0.0.1] File does not
exist: c:/programme/apache
group/apache/htdocs/meta-inf/services/javax.imageio.spi.ImageInputStreamSpi
[Tue Jun 08 11:40:22 2004] [error] [client 127.0.0.1] File does not
exist: c:/programme/apache
group/apache/htdocs/meta-inf/services/javax.imageio.spi.ImageWriterSpi
[Tue Jun 08 11:40:22 2004] [error] [client 127.0.0.1] File does not
exist: c:/programme/apache
group/apache/htdocs/meta-inf/services/javax.imageio.spi.ImageTranscoderSpi
i cannot explain this lines to myself, because my apache should have
nothing to do with java. all my javacode is executed on the client
side in the browser. do this messages mean i have to add the ImageIO
package from the sdk to my jar-applet. the jre, used by my iexplorer,
doesn't contain this files in the meta-inf/services directory of
rt.jar, but that's version 1.4.2_03, the same as my sdk, and the
rt.jar contains the corresponding classfiles at javax.imageio.spi. so
i'm realy confused by this messages.
2. try:
private void writeImageToServer(URL fileURL,BufferedImage img){
try {
URLConnection urlConnection = fileURL.openConnection();
urlConnection.setDoOutput(true);
OutputStream urlout = urlConnection.getOutputStream();
BufferedOutputStream out = new BufferedOutputStream(urlout);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(img);
out.close(); // same comments as above
catch( IOException e ){
e.printStackTrace();
result:
nothing. no error-messages in the error.log, no exceptions in the
java-console and no test.jpg in the webroot. i searched my whole
harddrives for it: nothing. isn't this the way, the JPEGImageEncoder
works?
3. try:
private void writeImageToServer(URL fileURL,BufferedImage img){
try {
File file = new File(fileURL.toString);
file.createNewFile();
BufferedOutputStream out = new BufferedOutputStream(new
FileOutputStream(file));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(img);
out.close(); // same comments as above
catch( Exception e ){
e.printStackTrace();
result:
the SecurityManager denies this action with "access denied" while
calling createNewFile(). well, this way was dedicated to run from an
application, not from an applet. i'd have to sign my applet to get the
rights to do this, or i can edit java.policy on my client, what i
don't want, because i cannot do this on every client, the applet will
run, when i'm finished with it. this brings me to the question: does
anybody know's how to sign my applet and give it full access to the
harddrive and the webserver without paying 400$ to VeriSign for a
commercial CA? i want to do this by myself, without paying anything
and without giving a lot of information to another company.
i would realy appreciate, if someone could give me a hint where i am
wrong or how to do this correct.
thank you very much
[email protected]

You hold several misconceptions. The first is that an applet can write to a server without help from the server. That will never work on a real server (though it might work in testing, if the server is on the same PC as the applet). Applets cannot get a File object that points to any place on the server.
If you write a servlet designed for accepting image uploads, the applet can communicate back to that servlet and feed it the bytes of the image. There are other technologies that can replace the servlet, of course (PHP, ASP..) but I mention that because you say you are running Apache - and that is very Java oriented.
For more help on servlets, try the [Web Tier APIs - Java Servlet|http://forums.sun.com/forum.jspa?forumID=33] forum.

Similar Messages

  • How to capture an image from my usb camera and display on my front panel

    How to capture an image from my usb camera and display on my front panel

    Install NI Vision Acquisition Software and NI IMAQ for USB and open an example.
    Christian

  • How to get all images from folder in c#?

    I am trying to get all images from folder. But it is not executing from following:
     string path=@"C:\wamp\www\fileupload\user_data";
                string[] filePaths = Directory.GetFiles(path,".jpg");
                for (int i = 0; i < filePaths.Length; i++)
                    dataGridImage.Controls.Add(filePaths[i]);
    Please give me the correct solution.

    How to display all images from folder in picturebox in c#?
    private void Form1_Load(object sender, EventArgs e)
    string[] files = Directory.GetFiles(Form1.programdir + "\\card_images", "*", SearchOption.TopDirectoryOnly);
    foreach (var filename in files)
    Bitmap bmp = null;
    try
    bmp = new Bitmap(filename);
    catch (Exception e)
    // remove this if you don't want to see the exception message
    MessageBox.Show(e.Message);
    continue;
    var card = new PictureBox();
    card.BackgroundImage = bmp;
    card.Padding = new Padding(0);
    card.BackgroundImageLayout = ImageLayout.Stretch;
    card.MouseDown += new MouseEventHandler(card_click);
    card.Size = new Size((int)(this.ClientSize.Width / 2) - 15, images.Height);
    images.Controls.Add(card);
    Free .NET Barcode Generator & Scanner supporting over 40 kinds of 1D & 2D symbologies.

  • HT4007 How do I export images from Aperture to my iPad Mini?

    How do I export images from aperture to my iPad Mini?
    Berndpeter

    I am going to give it a try.
    Greetings from Mexico!

  • How do I import images from my hard drive without losing resolution? My original files after import are significantly smaller. What should I do?

    How do I import images from my hard drive without losing resolution? My original files after import are significantly smaller. What should I do?

    Hi Keith, and all others chiming in, I do have the correct option checked in advanced settings telling iPhoto to copy the images into the library. What is a refernced library? Perhaps this is where I am getting confused. I exported my entire photo library from an old iMac5 to my external hard drive, from there I attempted to import the entire library to my new iMac. Am I overlooking an obvious and easy way to import from the hard drive to the new iMac--I dragged the entire photo pholder from the hard drive to the open window of iPhoto on the new computer. Now, I only get preview file sizes in iPhoto, unless I have my external drive open. Perhaps I need to import the original images from the hard drive in a different way...?! (This is making me feel pretty stupid.)

  • How do I remove images from aperture?

    Totally new to apple and aperture so I apologise if this seems like a somewhat noob question but how do I remove images from aperture (using the latest version, 3.4.1)? Coming from a PC and using lightroom I'm used to being able to remove images in two ways:
    - removing the image from the "library", so that it no longer shows up in the program at all but is still on your hard drive (when I say removing it from the program entirely, I mean entirely, i.e. not sitting in a trash can or some other place where it's still taking up memory)
    - deleting the original image off the hard drive
    Is it possible to do either of these things in aperture, on both just a single image or a selection of multiple images, and if so how? I've tried googling this already and am getting a bunch of mixed solutions, none of which have really worked so far, so any answers would be appreciated. Thanks!

    The answer partially depends on whether you have a managed or referenced library. Since you're totally new to Aperture, I'm assuming you have a managed library since that's the default.
    FYI: Managed means Aperture handles image files and places them inside the library file. Referenced means you manage the image files and Aperture only points to (references) them.
    For a managed library, select an image you want to delete. Type command-delete. (That's the reverse delete key next to the "=" key). (You can also right-click an image and choose Delete Version) That will remove the images from their Project and place in the Aperture Trash. They're still taking up space in the Trash. If you really want them gone for good, right-click the Trash in the library pane and select Empty Trash. Poof.
    For a reference library, I forgot the exact details since I don't use this type of library, but you'll be asked (or can check a box) to delete the original file from the disk.

  • How can I access images from IPhoto on my Mac to Photoshop CS6

    How can I access images from IPhoto library on my Mac to Photoshop CS6?  I enable jpg with format "Photoshop" and this is what comes up -  "Could not complete your request because Photoshop does not recognize this type of file" 

    MountainArtist wrote:
    …I enable jpg with format "Photoshop" and this is what comes up -  "Could not complete your request because Photoshop does not recognize this type of file" 
    Photoshop is not a format.  It's an application.
    What you are looking at are not true JPEGs, just iPhoto's "tease" representations of the hidden images it swallowed, as explained above.

  • How do I remove images from Notes app?

    How do I remove images from Notes app?
    I sometimes find that, when cutting and pasting text from the web, an image is also copied (pretty much at all times I try and avoid this, but sometimes the selection process doesn't allow for fine enough control - e.g. a whole block of content may be selected, rather than just the few words I'm trying to copy).
    I then find, once it's part of my note, that I cannot select the unwanted image and remove it. Can anyone tell me if this is something that can be done, and if so... how?
    Thanks, Sebastain

    Hi Drew & Kilgore*
    Thanks for your replies. I also have and use Simplenote, although I went off it for a while, when it started crashing all the time on me. It seems to be more stable again now, so I'll start using it more regularly again, perhaps.
    I am, obviously, disappointed that one can't simply select ANY object within a Notes document and choose to delete it. As I rather suspected, the only solution is an annoying workaround. Apple stuff seems to get more like this as time goes by. At least in my experience.
    I solved the issue my own way in the end, but I guess it was close to your 1st idea DR, and your 2nd option, KT: I basically cut and pasted everything above, and then everything below, the image, and pasted both chunks of text into a new note. So it took two passes, and left me with the original note just displaying the image, which I then trashed.
    Tapping to the right of the image followed by deletion was what I hoped & expected would work. But instead the image stayed put and the text below the cursor would simply slide along the right hand side, moving upwards as I deleted! Most bizarre, to my mind at least.
    Anyway thanks for the feedback. But, for anyone else that might want to know how to do this, the answer is: NO, you can't select and delete an image once it's in one of your notes!
    * I quite recently watched the rather strange Bruce Willis / Nick Nolte 'Breakfast of Champions' movie... I think I still prefer the book to the film!

  • How can I import images from iphoto with the albums and folders?

    How can I import images from iphoto without losing the albums and folders I already created?

    In Organizer, you can choose File>get Photos and Videos>From iPhoto.
    Importing from iPhoto'09: If in iPhoto, you organize your media using photo references, that is, the media actually does not reside inside iPhoto library package, and are referenced through original locations, Organizer does not create new copies of those media and just refer to the original location. but if your iPhoto media reside inside iPhoto library, Organizer creates a copy all media in your pictures folder, also imports albums and tags and other metadata.
    Importing from iPhoto'011: In this case, Organizer always creates a copy of your photos in your pictures folder which resides inside iPohto package. It does not import the albums and other metadata like star rating, caption etc.
    Hope this information helps!
    regards,
    vaishali

  • How to read some images from file system with webdynpro for abap?

    Hi,experts,
    I want to finish webdynpro for abap program to read some photos from file system. I may make MIMES in the webdynpro component and create photos in the MIMES, but my boss doesn't agree with me using this way. He wish me read these photos from file system.
    How to read some images from file system with webdynpro for abap?
    Thanks a lot!

    Hello Tao,
    The parameter
       icm/HTTP/file_access_<xx>
    may help you to access the pictures without any db-access.
    The following two links may help you to understand the other possibilities as well.
    The threads are covering BSP, but it should be useful for WebDynpro as well.
    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents
    http://help.sap.com/saphelp_sm40/helpdata/de/c4/87153a1a5b4c2de10000000a114084/content.htm
    Best regards
    Christian

  • How do I acquire images from my usb webcam ?

    Hi all ,
    How do I acquire images from my usb webcam (logitech quickcam express ) ?
    I use Labview 7 .

    Pedrus wrote:
    > Hi all ,
    > How do I acquire images from my usb webcam (logitech quickcam express)?
    > I use Labview 7 .
    This seems a very popular question coming up about once every week at
    least. And there are many good answers in the developer Zone on www.ni.com
    Check out:
    Irene He's IVision Toolkit:
    http://www.hytekautomation.com/Products/IVision.html
    or
    Pete Parentes WebCam library:
    http://www.cs.unc.edu/~parente/labview/index.shtml
    The first is a rather impressive Video Manipulation library with a
    nice video capture interface to VfW too, and the second is a simple
    video capture library to access any VfW compliant device.
    Rolf K"
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to download RAW images from Canon S100 to iPhoto?

    How to download RAW images from Canon S100 to iPhoto?

    You need the Raw compatibility update 3.9:
    http://support.apple.com/kb/DL1473

  • How do you load images from a Win7 machine to iPhone?

    Hi. How do you load images from a Windows 7 PC to an iPhone 4? I'd like to load the pictures to use as wallpapers. Thanks.

    You CANNOT transfer photos from your computer to your iPhone when connected to your computer as an external drive. This is for transferring photos and/or video from your iPhone's Camera Roll to your computer's hard drive ONLY.
    To transfer photos from your computer's hard drive to your iPhone, this is selected under the Photo's tab for your iPhone's sync preferences with iTunes followed by a sync.

  • How can I download images from my iphone to adobe bridge cs5

    How can I download images from my iphone to adobe bridge cs5?  I don't want to use iPhoto.

    "How can I download photos from my iphone to mac?"
    Same way as with any other digital camera.
    "Do I need to use Iphoto? "
    Yes.
    "Why doesn't my Mac come with Iphoto application? "
    It does. All macs come with iphoto.
    Copying personal photos and videos from iOS devices to your computer

  • How can I extract images from Numbers?

    Sounds a bit stupid but how do you extract images from Apples 'Numbers 3' on a Mac?  I have a client that sends images in XLS files, that normally in Word I would Alt Click and 'save as...'
    I was trying to stop using Word but this simple little feature will make all the difference.
    Can anyone point me in the right direction.
    Thanks,
    Dave

    Hi Wayne,
    Thank you for your response.  Sadly if you do this it copies in to the MACs clipboard as a snap shot of the image at the dimensions in Numbers.
    Eg. 
    An image I've extracted from the document via Excel saved out at it's original dimensions 1024 x 300px, even though it was placed, then scaled down to 300px wide on the sheet.
    Same image copied then pasted in to an image editor (as I couldn't paste into finder) was only 300px wide.
    The feature I need is to be able to save out the original image placed in the Numbers sheet.
    Anyone with ideas on this?

Maybe you are looking for

  • Muse trial upgrade

    Upgrade from trial muse to creative cloud. When opening Muse get message trial has expired. Hit continue button and enter Adobe id, email and password and get message. An unexpected error occurred processing your request. Please try again later. Have

  • HT201304 How to prevent the poster/icon of explicit movies from showing up in the Top Hits list

    Although i have setup up all the parental controls to prevent adult/explicit content in the movies (Apple TV), still the posters of adult movies often show up in the Top hit List, is there a way to prevent the poster from showing up in the list too ?

  • Photoshop CS5 stopped working

    I downloaded and installed the CS5 Design Premium suite. (I already had CS4 installed and working on my computer.) I used Photoshop (64 bit), Bridge, InDesign and Illustrator. I have opend and closed each of these programs several times. I have used

  • New IPhone has random person's email as Apple ID

    I just got my first iPhone today, and when I tried to download some apps it asked me for my Apple ID password, but it reads: "Enter the Apple ID password for '[email protected]'" I have no idea who Angelo Pezzino is, and it won't let me do anything b

  • Apps can't install themselves?

    Hello! I have a new problem since yesterday. I have an iPhone 4 and everything wetn awesome, until I wanted to download an update. The bar, that says waiting under it appeared, and it can't finish downloading. Internet works well, I wanted to delete,