Servlet stream images

hi, everybody:
i have been working on a project that display images: it receives an alive image stream from a servlet running on a different server. i would like to use the img tag to diplay the image, like this:
<img src=ImgServlet?search_id=111>it works very well, impressivly efficient. only problem is when the ImgServlet does not find the image, it return a string message instead of a binary image stream, which of course screw up the page with a broken image icon. so the solution is to invoke the servlet once to determin what the stream is: a message or an image, then it seems that you have to call the servlet again once the type of the stream is determined. this works but i hope there is a better way of doing this. could someone help?

BalusC wrote:
Indeed. Your ImageServlet can perfectly detect non-existing images and handle it on its own.
Here you can find an example: http://balusc.blogspot.com/2007/04/imageservlet.html
thanks for the info. i guess i didnot make myself clear enough. i am invoking a servlet on a remote server to get a stream of binary data for an image. sometimes an image may not exist, and that servlet will sream back a text message stating the reason why the image is not found. since i dont know if the stream will be of binary image data or a text data, i found it to be hard to manage it, ie, when a text is streamed back, the <img src=text> will break. now i am englightened, my servlet will turn that text stream into a binary image/jpeg with that message printed on it, this way it can be managed.

Similar Messages

  • How to stream images to an iPad ?

    I am a photographer and want to stream images as I shoot them into a Macbook Pro to an iPad (for an Art Director). Shooting tethered into Aperture or Capture One. But can set up a 'hot folder'.
    Gernerally in a studio or location house with wifi.
    Need help how to set this up.
    Many many thanks.  

    I've posted an idea over here:
    http://discussions.apple.com/thread.jspa?threadID=2531816
    Please don't post the same question in multiple forums ...

  • How to stream images to ipad

    I am a photographer and want to stream images as I shoot them into a Macbook Pro to an iPad (for an Art Director). Shooting tethered into Aperture or Capture One. But can set up a 'hot folder'.
    Gernerally in a studio or location house with wifi.
    Need help how to set this up.
    Many many thanks !!!

    Have you thought about using an Eye-Fi SD card? They have WiFi and can transfer photos from the camera to a computer while shooting. For the iPad, there's an app called ShutterSnitch that can receive the photos from the Eye-Fi card.

  • HT201317 Cant get Camera Roll or Photo Stream images off my iphone 4

    Cant get Camera Roll or Photo Stream images off my iphone 4.  Ive got everything turned on to support the icloud function and my itunes shows syncing, but nothing. Any ideas what Im missing?  Thanks A Million!

    You can delete them from your phone by opening the album that contains them, tap Edit, tap the photos you want to delete, the tap Delete.  You can also import camera roll photos to your computer and delete them after importing as explained in this article: http://support.apple.com/kb/HT4083.

  • "streaming images"

    Hello,
    I m streaming images from the camera and using the doja (like j2me)profile but it only supports http communication which i know only supports one request and response. I m getting some delayin getting live images.as connection is not fast.
    Can u tell me if in a single request ,without requesting further can i get the images or data ie connection alive in http. Mobile got limitation that it only getting 150 kb at the client end at one single connection.
    Thanks

    If you are running Java 1.5.x you might want to try http://java.sun.com/j2se/1.5.0/docs/api/java/util/jar/package-summary.html - the Pack200 web deploy compression.

  • Displaying streamed images in Web Dynpro

    Hi All,
    I have following scenario to programme.
    - The DB have "images" stored as BLOB.
    - I need to read the images (stream) and make them visible in Web Dynpro UI.
    Problem is i only one way to providing images in Web Dynpro. The images are picked from url that points to Resource either at temporary location of permanent position Sap Images pool or contribution under mimes folder.
    I see temporary location as one option here but still not able to figure out where to store it !
    Can anybody help in this.
    Thanks and Regards,
    Ashwani Kr Sharma

    Hi ,
    Use
    WDWebResource.getPublicCachedWebResource(byte[] webResource,
                                                                  WDWebResourceType resourceType,
                                                                  WDScopeType scopeType,
                                                                  WDDeployableObjectPart deployableObjectpart,
                                                                  String key)
    Regards
    Bharathwaj

  • Photo Stream Image Size to iPad

    Is there a way to set the image size dementions that are uploaded via Photo Stream to iPad?

    The image size is determined automatic. See iCloud: Photo Stream FAQ
    What resolution are My Photo Stream photos?
    On your Mac or PC, your photos are downloaded and stored in full resolution. On your iPhone, iPad, iPod touch, and Apple TV, your Photo Stream photos are delivered in a device-optimized resolution that speeds downloads and saves storage space. While actual dimensions will vary, an optimized version of a photo taken by a standard point-and-shoot camera will have a 2048 x 1536 pixel resolution when pushed to your devices. Panoramic photos can be up to 50 pixels wide.
    Regards
    Léonie

  • Shared Photo Stream Image Order

    Has anyone figured out how to alter the order of a shared photo stream? I added a set of select images to my stream via Aperture and they display out of order on my iPhone/iPad. They also display out of order for those who subscribe to my stream. The order seems randomn - not how I ordered them in Aperture and not ordered by name or time.

    I believe pvonk is correct, at least for now. Very unfortunate.

  • Servlet with image

    i want to create a servlet that read a image file from hard disk after that display that image in web browser

    your servlet would look something like this :
    byte[] imageBytes = // here you would retrieve the image bytes
    response.setContentType("image/jpeg");
    response.getOutputStream().write(imageBytes);let's say your web-apps context is /Test and the servlet is mapped to /ImageServlet your html would look like this :
    <img src="/Test/ImageServlet" />now you can also specify request parameters so the servlet can load different images eg.
    <img src="/Test/ImageServlet?imageId=100" />in the servlet, you would then retrieve the imageId property and get the image using that id.
    Hope that helps?

  • Randomly getting someone elses photo stream images

    Hi,
    My friend is on an iPhone 5 and has had the phone since November. Over the last few hours a couple of photos have started appearing in his photostream interspersed with his own photos.
    From the looks of the images (here : http://imgur.com/a/1EAm4) it would appear it's some sort of Apple repair facility, particularly the image with the iPhone 4 screw mats.
    It's my belief that somebody is repairing a phone and testing some of its functionality, and somehow it has assigned itself to the same icloud ID as my friends.
    This is pretty unsettling, however the more concerning issue is whether this other user is also getting my friends photostream downloaded to his phone.
    Has anyone else encountered this / can anyone recommend the best next steps?
    Images: http://imgur.com/a/1EAm4
    Sam

    You can use the Photos app to access the stream.
    Matt

  • How to stream images to multiple ATVs?

    I would like to install 5 large screen monitors throughout an office for advertising purposes.  I will display an image that changes about every 30 seconds.  I could use iPhoto, Keynote, Quicktime, or whatever works best. 
    The question is, with a good dedicated server, can I stream to 5 ATVs simultaneously?  If not, any better ideas how to achieve this?  I could go with a wired network, but would prefer wireless.  I am open to a solution other than ATV if needed.
    thanks!

    I've no idea if there is a certain processor that would be needed, I've been streaming to multiple Apple TV's since they came out and not had a problem on various computers. If you are going to encounter a problem it will likely be with your network rather than your computer, the computer does very little but send the data it's requested to.
    5 Apple TV's might place too much of a load on a wifi network that isn't working as well as it should be, either because the distances are too great or it's experiencing interference. I tend to have a lot of data flying around my network, in addition to my 6 Apple TV's, we have several HD security cameras that use the network as well as a couple of iPads, 4 phones and numerous computers and other devices.
    To accommodate all this traffic I use more than one wifi base station all using the same network and linked via ethernet. This is what I do, it's a little out of date now, we have 3 Apple TV 1's and 3 Apple TV 2's now instead of 5 Apple TV 1's and a couple fewer phones, but you'll get the idea.
    The Apple TV outputs at 720p depending on the TV you have the TV will scale the output accordingly. It doesn't matter how high a resolution the photos are they can never be scaled to more than 1920 x1080 on a TV screen as that's the maximum resolution of a TV.
    How often the slideshow repeats depends on how long each slide is displayed for and how many there are. If you have (say) 100 slides and they each last for 20 seconds, the slideshow will repeat after 33 minutes and 20 seconds.

  • Servlet results image - intermittent error

    Hi!
    I have an html that calls a servlet from the src of an image tag. The servlet brings a image as result. The intermittent error is that the image doesn't appears in the very first time. Only when I refresh the page is that the image appears. If I call the page from another browser, the image always appears. But if I restart the application server, the image doesn't appear at the first time, again.
    I use the WebSphere Application Server 3.5, and develop the applications with VisualAge for Java 3.5. In both environments the error occurs.
    Can someone helps me?
    thanks
    html: index.html
    <HTML>
    <HEAD>
    </HEAD>
    <BODY bgcolor="#FFFFFF">
    This is your logo:
    <p><img src="servlet/pLog.Counter"></p>
    </BODY>
    </HTML>servlet pLog.Counter
    package pLog;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import com.sun.image.codec.jpeg.*;
    import java.awt.image.*;
    import java.awt.*;
    public class Counter extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
              doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
              response.setContentType("image/jpeg");
              ServletOutputStream out = response.getOutputStream();          
              String strImagePath = "http://localhost:8080/images/logogedas.jpg";
              Toolkit toolkit = Toolkit.getDefaultToolkit();
              URL urlIMAGE =     new URL(strImagePath);
              Image image1 = toolkit.getImage(urlIMAGE);
              int iWid = image1.getWidth(null);
              int iHei = image1.getHeight(null);               
              BufferedImage image = new BufferedImage(iWid,iHei, BufferedImage.TYPE_INT_RGB);
              Graphics g = image.getGraphics();
              g.drawImage(image1, 0, 0, null);               
              JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
              encoder.encode(image);
              out.close();
    }

    Hi,
    You'll need to define a MediaTracker to wait for the image to be loaded completely. Here's the modified code:
    package pLog;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import com.sun.image.codec.jpeg.*;
    import java.awt.image.*;
    import java.awt.*;
    public class Counter extends HttpServlet {
         public void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, java.io.IOException {
                   doPost(request, response);
         public void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, java.io.IOException {
                   response.setContentType("image/jpeg");
                   ServletOutputStream out = response.getOutputStream();
                   String strImagePath = "http://localhost:8080/images/logogedas.jpg";
                   Toolkit toolkit = Toolkit.getDefaultToolkit();
                   URL urlIMAGE =     new URL(strImagePath);
                   Image image1 = toolkit.getImage(urlIMAGE);
                   Frame frame = new Frame();
                   frame.addNotify();
                   MediaTracker tracker = new MediaTracker(frame);
                   tracker.addImage(image1, 0);
                   try {
                        tracker.waitForAll();
                   catch (InterruptedException e) {
                        log("Interrupted while loading image");
                        throw new ServletException(e.getMessage());
                   int iWid = image1.getWidth(null);
                   int iHei = image1.getHeight(null);
                   BufferedImage image = new BufferedImage(iWid,iHei, BufferedImage.TYPE_INT_RGB);
                   Graphics g = image.getGraphics();
                   g.drawImage(image1, 0, 0, null);
                   JPEGImageEncoder encoder =JPEGCodec.createJPEGEncoder(out);
                   encoder.encode(image);
                   out.close();
    }Another possibility is to implement the ImageObserver interface (although it's a little more complicated).
    Hope this helps,
    Kurt.

  • Virtual Streaming images

    Hello,
    I'm fairly new to Java. I first started with applets, and just recently learned just a little bit about servlets to help supplement my applet I have been created.
    This applet takes input from the user, such as date and time. And with this input, it starts cycling through JPG images. The user can pause, stop, play, etc. Basically, a slideshow. This works great with smaller amounts of images. But with a whole lot of images, I'm sure it will take a HUGE amount of time to retrieve the images, etc. I have not research JSP, and I was wondering if this application would be better suited for JPS instead of applets. Also, if so, if anyone has any suggestion on where to start, maybe some links, or tuterials, it would be greatly appreciated.

    Well, you could certainly do a slide show with JSP... actually, you could do it with Javascript and plain HTML (one example is weather.com, they have this "show map in motion" option on most maps, which is done in JavaScript).
    But I think the reason you are having problems is it sounds like you are trying to load all the images at startup. You should only load each image as needed, stored in memory after you load them, of course. This would really be the same way it would happen as a HTML/JavaScript slide show, since you wouldn't really have any other choice.

  • Stream image with jmf

    Hi guys,
    1) do you know how I can create in JMF a DataSource or processor with the info of a YUV image?
    Usually programmers who use JMF initialize the DataSource by using a capture device or a MediaLocator. What I need now is simply to create a DataSource with a YUV image info as data to transmit..
    2) Do you know how to stream a YUV image from one PC to another?
    Thanks guys & cheers
    CM

    Have you cleared this problem. I am having the same problem right now. Till now amn't able to clear it.
    One thing in my mind is that first of all I need to convert the JPeg images to a movie and after that transmit it...
    If you have cleared thsi problem, I'll be grateful if u can help me...
    Thanks
    Sco

  • Servlets and images

    I've created a servlet that generates a number of HTML files depending on the Parameters passed to it. This works fine, but the problem I'm having is where to put the images (backgrounds, etc) so the browser viewing the HTML files can pick them up. I'm using the Internal JDeveloper web server app. Do I have to use an absolute path (i.e. c:\images\back.gif)?
    Help!!!!

    It's OK, I've managed to find it. for those of you looking for it it is the obviously named 'HTML root directory' in project properties/paths.
    null

Maybe you are looking for

  • Can't figure out how to register my nano?

    long story short, I accidentally clicked the "never register" button on the screen when i plugged in my iPod Nano to my comp to charge (not the first time). Later, I realized that i needed to register my nano to do something, even though the first th

  • CUOM error when trying to poll performance data from IPCC Express

    Hi Network Professionals, Using CUOM 2.1 SP1 I get an error when trying to access the Performance menu for a IPCC Express Server in the Service Level View. Error Message: Performance polling is not supported for the current capability. The server is

  • Export Import in Portal Rel 2

    Hi How do i export/import Pages and other contents in portal rel 2, pageexp/imp and appexp/imp scripts r not to be found..what has happened to these in Rel 2.. TIA Bijesh

  • IDVD PAL and NTSC errors before burning-

    Hi anybody- I'm now getting an error when I hit the button to burn a DVD in iDVD 7.0.3. The error say that I am trying to burn a PAL movie to to an NTSC disc. The movie is in a .mov format, and I have NTSC selected in project info, professional setti

  • Stock transfer Order Return process

    Dear Expert, We are using plant to plant stock transfer for semi fineshed and finished materials. We are using STO with delivery Need you help in getting solution for following scenarion. 1. STO creating. 2. Delivery created against STO 3. Goods Move