Need an ascii image format!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bura Tino

    #1

    Need an ascii image format!

    Hi,

    I developing a system using JSP. People familiar with this technology
    know that ServerPages are easier to maintain than Servlets, but they
    can only have ASCII output.

    With that as the backdrop, here's what I want to accomplish. I want
    clicking on a link to cause a script to be executed on the server but
    -->I don't want the browser to jump to another page<--.

    A solution that I conceived was to have javascript like

    someimage.src = 'http://myscript'

    This will accomplish the task and it would be great if myscript return
    an image of a checked checkbox! But, because of JSP limitations this
    would need to be an ASCII image.

    So my question is twofold:
    1. Are there convenient ASCII image formats?
    2. Is there another way to accomplish what I want (trigger some action
    on the server without jumping to another page and using js to display
    a sensible response - something like a check)?

    Thanks!

    Bura
  • Richard Cornford

    #2
    Re: Need an ascii image format!

    Bura Tino wrote:[color=blue]
    > I developing a system using JSP. People familiar with this technology
    > know that ServerPages are easier to maintain than Servlets, but they
    > can only have ASCII output.[/color]
    <snip>

    Not true, you can output anything from a JSP because a JSP is a
    servelet. You just have to be careful not to output any character data
    (including CR/LF pairs) prior to resetting the response and starting to
    output binary e.g.:-

    <%@ page language="java" import=",java.i o.*,java.util.* "%><%!
    final static byte[] spacer = {
    71, 73, 70, 56, 57, 97, 1, 0, 1, 0, -128, 1, 0, -1, -1, -1,
    0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59
    };
    %><%
    try{
    response.reset( );
    response.setCon tentType("image/gif");
    OutputStream outStream = response.getOut putStream();
    synchronized(re sponse.getOutpu tStream()){
    outStream.write (spacer);
    }
    response.flushB uffer();
    }catch(IOExcept ion e){
    System.out.prin tln("IO Exception details 1 : " + e.getMessage()) ;
    }catch(Exceptio n e){
    System.out.prin tln("Exception details 2 : " + e.getMessage()) ;
    }%>

    But JSP is OT here.

    Richard.


    Comment

    Working...