Solved

using image url in jsp through velocity

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 116
VB.net and sql server 4 45
Forms that calculate points for wordpress 10 50
Disable TLS1.0 on Win 2012 server 7 26
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

839 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