Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

using image url in jsp through velocity

Posted on 2013-11-15
1
Medium Priority
?
439 Views
Last Modified: 2013-11-18
Hi,
I have a jsp in which i am trying to get image from a local directory through a service.
The service is :
http://local.yatra.com:8080/fresco/resources/images/city/goa.jpg

I am getting the city names from another webservice
By looping over the city names i need to fetch the image corresponding to the city.

Here is my jsp :
--------------------
#foreach($requestMap in $requestMap.moduleData)
      #foreach($i in $requestMap.root)
            <div class="singleOffer">
                  <a href="$i.searchURL" class="offerHead">
                        <b href="$i.searchURL" class="txtMedium block">$i.cityName</b>
                        <!--<span class="block">Cosy Beach village</span>-->
                  </a>
                  <a href="$i.searchURL" style="width:142px;height:102px; display: block;overflow: hidden;"><img src="http://local.yatra.com:8080/fresco/resources/images/city/${i.cityName}.jpg"/></a>
                  <a href="$i.searchURL" class="pattern1">
                        <p class="flL mr5">Starting from</p>
                        <span class="txtYellow latoBold"><span class="RupeeSign">Rs.</span>
                            %{cms.handler.currencyFormatter:$i.startingPrice}%
                </span>
                        <!--<p>3 nights/person</p>-->
                  </a>
            </div>
            #end
            #end
----------------------------
The problem i am facing is in the line :
<img src="http://local.yatra.com:8080/fresco/resources/images/city/${i.cityName}.jpg

I have tried all kinds of combination like using '' single quotes on i.cityname or appending it as a string to the src url.
But the always unable to retrieve the image. If i check the ctrl+u source page
I see sometimes the cityname remains constant or "+" sign gets appended in the url
due to which it is unable to get the image.

Please help!

Thanks
Robin
0
Comment
Question by:Rohit Bajaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
Rohit Bajaj earned 0 total points
ID: 39656041
a<!-- start  "hotels" popular destinations -->
<section class="ytRow blockBox">
      <div class="sprite dragIcon"></div>
      <div class="blockHead">
            <span class="heading txtXXX txtBlue latoBold">%{cms.handler.languageHandler:popular-destinations,module_title}%</span>
            <span class="subHeading">
                  <span class="txtGrey">%{cms.handler.languageHandler:popular-destinations,browse_among_text}%</span><br/>
                  <a href="http://www.yatra.com/india-tour-packages">%{cms.handler.languageHandler:popular-destinations,destination_guide_text}%</a>
            </span>
      </div>
      <div class="offersOuter relative">
      <div class="carouseldiv">
      #set( $ext = ".jpg" )
      #foreach($requestMap in $requestMap.moduleData)
      #foreach($i in $requestMap.root)
            <div class="singleOffer"  title='$i.cityName - Starting from %{cms.handler.htmlTagHandler:<span class="RupeeSign">Rs.</span>}% %{cms.handler.currencyFormatter:$i.startingPrice}%'>
                  <a href="$i.searchURL" class="offerHead">
                        <b href="$i.searchURL" class="txtMedium block" title='$i.cityName'>$i.cityName</b>
                        <!--<span class="block">Cosy Beach village</span>-->
                  </a>
                  <a href="$i.searchURL" class="imgSizeFix"><img src="http://local.yatra.com:8080/fresco/resources/images/city/${i.cityName.toLowerCase()}${ext}" alt=""/></a>
                  <a href="$i.searchURL" class="pattern1">
                        <p class="flL mr5">Starting from</p>
                        <span class="txtYellow latoBold"><span class="RupeeSign">Rs.</span>
                            %{cms.handler.currencyFormatter:$i.startingPrice}%
                </span>
                        <!--<p>3 nights/person</p>-->
                  </a>
            </div>
            #end
            #end
            <i class="sprite prev"></i>
            <i class="sprite next"></i>
            </div>
      </div>
</section>
<!-- eof  "hotels" popular destinations -->

The above code worked.
I set the extension of the filenames and then apended them to the image url
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question