Solved

using image url in jsp through velocity

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

735 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