Generate javascript code by Servlet Problem

A

alan

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
 
C

Chris Riesbeck

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.
 
N

Neomorph

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top