Home Ask Login Register

Developers Planet

Your answer is one click away!

Himanshi February 2016

How to pass image path in js function

I'm trying to pass the image path dynamically from one JSP page to another using a JS function, but the image path I get in a JS alert is different. The correct path is .\Products\767\76\suitmed.jpg however the alert shows me this .\Products>7>suitmed.jpg. Can some one please help me with this.

enter image description here


<c:forEach items="${products}" var="products">
    <div class="col-sm-4">
        <div class="product-image-wrapper">
            <div class="single-products">
                <div class="productinfo text-center">
                    <!--here in this Image tag I was trying to pass the path od med and large img from product obj -->
                    <img src="${products.smallImage}" onclick="getImageDetails('${products.mediumImage}', '${products.largeImage}'); return false;" alt="${products.productId}+productImage" />
            <div class="choose">
                <ul class="nav nav-pills nav-justified">
                        <a href="">
                            <i class="fa fa-plus-square"></i>
                            Add to Wishlist


function getImageDetails(mediumImagePath, LargeImagePath) {
    alert(mediumImagePath + "_______" + LargeImagePath);
    $("#bigImage").attr("src", mediumImagePath);



Henrik February 2016

Never programmed jsp, but here is a plausible explanation:

\## is interpreted as an octal character escape sequence.

Char    Octal   Dec Hex Description
<        74     60  3c  Less than sign (&lt; in HTML)
=        75     61  3d  Equals sign
>        76     62  3e  Greater than sign (&gt; in HTML)
?        77     63  3f  Question mark

so "\76" becomes ">" when printing..

try replacing all "\" with "/" in paths that usually helps you out, and most webservices can already handle the translation from unix styled paths to windows styled..

Post Status

Asked in February 2016
Viewed 1,522 times
Voted 6
Answered 1 times


Leave an answer

Quote of the day: live life

Devs Planet ®

2014-2016 www.devsplanet.com

Devs Planet © all rights reserved