Solved

using image url in jsp through velocity

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A short article about a problem I had getting the GPS LocationListener working.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

861 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

25 Experts available now in Live!

Get 1:1 Help Now