Solved

using image url in jsp through velocity

Posted on 2013-11-15
1
397 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
1 Comment
 

Accepted Solution

by:
Rohit Bajaj earned 0 total points
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
A short article about problems I had with the new location API and permissions in Marshmallow
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
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 …

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now