Generate javascript code by Servlet Problem

Discussion in 'Java' started by alan, Aug 15, 2003.

  1. alan

    alan Guest

    HI all,

    I am a newbie on Java servlet.

    I have a problem on servlet.

    My case is following.

    I write a servlet to read JPG image files on server side and then post
    each read image to client browser. (This server works fine.)

    Here is a part of my java code to show images:
    -------------------------------------------------------------------------------
    for (int i = 0; i < imgQty; i++)
    {
    writer.println("<img src=\"..\\..\\test\\images\\" +
    imgFileLink.elementAt(i) + "\"" + " width=15%>");
    }
    -------------------------------------------------------------------------------

    I want to add a hyperlink on this image when client clicks this image,
    there is a new client browser will be created to show the image
    indiviually.
    My problem is how can I do this? what should I add to my java servlet.
    Could anybody give me some samples?

    Pls help.
    Thank you very very much.
    cheers,
    Alan
     
    alan, Aug 15, 2003
    #1
    1. Advertising

  2. In article <>,
    (alan) wrote:

    >I write a servlet to read JPG image files on server side and then post
    >each read image to client browser. (This server works fine.)
    >
    >Here is a part of my java code to show images:
    >-------------------------------------------------------------------------------
    >for (int i = 0; i < imgQty; i++)
    >{
    > writer.println("<img src=\"..\\..\\test\\images\\" +
    > imgFileLink.elementAt(i) + "\"" + " width=15%>");
    >}
    >-------------------------------------------------------------------------------
    >
    >I want to add a hyperlink on this image when client clicks this image,
    >there is a new client browser will be created to show the image
    >indiviually.
    >My problem is how can I do this? what should I add to my java servlet.
    >Could anybody give me some samples?


    You don't need javascript unless you want to resize the new window.
    Just wrap

    <a href="imagefile_url" target="_blank"> ... </a>

    around your <img ...> element.

    If you want to size the window, then Google for
    javascript image popup window to get lots of
    code examples.
     
    Chris Riesbeck, Aug 15, 2003
    #2
    1. Advertising

  3. alan

    Neomorph Guest

    On 15 Aug 2003 00:54:26 -0700, (alan) two-finger
    typed:

    >HI all,
    >
    >I am a newbie on Java servlet.
    >I have a problem on servlet.
    >My case is following.
    >
    >I write a servlet to read JPG image files on server side and then post
    >each read image to client browser. (This server works fine.)
    >
    >Here is a part of my java code to show images:
    >-------------------------------------------------------------------------------
    >for (int i = 0; i < imgQty; i++)
    >{
    > writer.println("<img src=\"..\\..\\test\\images\\" +
    > imgFileLink.elementAt(i) + "\"" + " width=15%>");
    >}
    >-------------------------------------------------------------------------------


    What's with the backslashes ?
    In a browser, directories are references with forward slashes:

    writer.println("<img src=\"../../test/images/" +
    imgFileLink.elementAt(i) + "\" width=15%>");

    >
    >I want to add a hyperlink on this image when client clicks this image,
    >there is a new client browser will be created to show the image
    >indiviually.
    >My problem is how can I do this? what should I add to my java servlet.
    >Could anybody give me some samples?


    You put the extra text around it:
    <A HREF="link" TARGET="_new"><img...></A>

    Standard HTML.

    >
    >Pls help.
    >Thank you very very much.
    >cheers,
    >Alan


    Cheers.
     
    Neomorph, Aug 16, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Weng Tianxiang
    Replies:
    5
    Views:
    1,357
    Christophe
    Feb 16, 2006
  2. circuit_breaker
    Replies:
    2
    Views:
    2,094
    Jack Jia
    Apr 4, 2004
  3. Replies:
    7
    Views:
    980
    Alan Krueger
    Jun 25, 2005
  4. Replies:
    3
    Views:
    440
    red floyd
    Apr 7, 2006
  5. Harlan Messinger
    Replies:
    2
    Views:
    2,356
    John Bell
    Mar 28, 2010
Loading...

Share This Page