We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


how to you c:if tag ?

sdesar asked
Medium Priority
Last Modified: 2010-04-01

how to implement JSTL (maybe c:if) to do the following:-

 String sImageUrl = JP.getPreviewImageURL((DbNode)imgNode, 500, 500);  // url to the image with width and height
             String sImageFull =  JP.getPreviewImageURL((DbNode)imgNode, 700, 700);  // url to the image with width and height

<a href="GetPreview.jsp?">
          <img src="<%=sImageUrl%>">

if user clicks of the anchor <a> then I want to change the
img source to the large image ie --

 <img src="<%=sImageFull%>">

awaiting a rresponse

Watch Question

jstl cannot do this!
you need javascript to do it.
or if you can discribe more detail of your problem. hope I'll see it differently.


Ok JavaScript should be okay for Onclick to check if its true .., but I think

if the onClick enent is true then I want to display <img src="<%=sImageFull%>">
else default is
<img src="<%=sImageUrl%>">

I just need to display a larger size image when the user clicks on the <a> tag and display this img src tag <img src="<%=sImageFull%>">

-Hope this helps
then you'll have to pass a parameter to sever.
or you can use javascript to change the image src righ in place.


could you please give me the syntax for the JavaScript .. if that is easier

awaitng a reposnse
give you img tag and id and get the tag, then tag.scr=newimageurl

<img src="<%=sImageUrl%>" onclick="this.src='<%=sImageFull%>'" >



I think all I need is to check is <a> tag is clicked then display <%=sImageFull%>
using JSTL c:if .. is that possible?

here is what I tried with your suggestion and it is NOT working

  <%-- OnClick
        <a href="GetPreview.jsp?"  onclick="this.src="<%=sImageFull%>"> <img src="<%=sImageUrl%>" > </a>

HTML result
            <a href="http://rabbits10.jpg&width=3065&height=2176&format=jpg" > 
        <img src="http://rabbits10.jpg&width=500&height=500&format=jpg">

so i see that its being outputed in HTML source but not on the HTML screen
Unlock this solution and get a sample of our free trial.
(No credit card required)


Here are your Excellent points!

This works!

img src="<%=sImageUrl%>" onclick="this.src='<%=sImageFull%>'" >

Thanks a million!
glad to know and my pleasure :)
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.