• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

jstl <c:import url= /> not working

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I'm trying to use jstl c:import and I'm just getting junk. I just tried:

<c:import var="data" url="http://ichart.finance.yahoo.com/t?s=IBM" />
<c:out value="${data}"/>

the taglib is:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

I've also tried without the var="data" and the c:out and all I get is junk displaying, not an image. And, no, there are no compile or runtime errors. Below is what I'm getting:

‰PNG  IHDR¾_Ùêí”IDATxœí{PSWþÀ¿÷&!! y€€(ëQéÏW·Nm;ÝŸ­µÕ­­níXmíŽÝ®vwqµŒ­ÔêhÛµÓí¿µS]GeZ§Zº[§ÀŠbiP ¼ ä!Â#!{z¹^D„,÷3LæžsÏ9÷{“/ßó½ç|ϹI’ÀÂrÿp©£‚‚‚eË–uwwëõúeË–ŽãÁÁÁï¾ûîk¯½†ÎFFFšL¦ŽŽ¥R ÝÝÝR©tªDÍÍÍF£ÇqˆŽŽV©TŒF£1**Šž388xõêÕGy%[[[ëëë1 KHH u{F„Ýn×ëõ.— Çñ9sæðùü±45:/^‹ÅèX Ì™3‡žér¹d2™V«-))€îîn™Liii㸮§F£Q,òÉ';wî|å•WPfWWWCCCYY™@ °Ùl~y/c2™ÌfsZZŽãA”——ã8A/sóæMºê˜Í檪*‡ÃAåÔÕÕ-^¼˜ ˆââb·¿÷È*ˆššµZÖÖÖV[[›’’rϦî

Why isn't the image displaying?

Thanks
Dave
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's an image? You can't just blurt out the image data in the middle of HTML and expect something good to happen.

Answer the following question:

  • What's the proper way to display an image in HTML?
  •  
    David Pantale
    Ranch Hand
    Posts: 32
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Thanks for replying. Okay, I got the image to display by this:

    <img border="0" src="http://ichart.finance.yahoo.com/t?s=IBM" />

    Obviously I misunderstood the c:import tag! However, the code samples I saw all seemed to use just the <c:import> in that fashion.

    I was using this code from tutorialspoint.com

    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
    <head>
    <title><c:import> Tag Example</title>
    </head>
    <body>
    <c:import var="data" url="http://www.tutorialspoint.com"/>
    <c:out value="${data}"/>
    </body>
    </html>

    So, if I want to include the whole web page in my jsp, what's the best way?

    Thanks
     
    Marshal
    Posts: 28295
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Are you seriously saying you found multiple examples which told you to use <c:import> to import an image? Can you provide links to those examples? Because I suspect they are really examples like the one you posted which import HTML. Which is what <c:import> is for.
     
    David Pantale
    Ranch Hand
    Posts: 32
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Sorry, I simply meant that the examples weren't (to me, anyway) entirely clear and I made some assumptions.
     
    Paul Clapham
    Marshal
    Posts: 28295
    95
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    David Pantale wrote:Sorry, I simply meant that the examples weren't (to me, anyway) entirely clear...



    One of the hazards of learning new subjects!
     
    Bear Bibeault
    Sheriff
    Posts: 67750
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    The <c:import> action will suck in the response of the URI passed to it, and emit it directly to the JSP response. So if it's an image, it'll just dump the image data into the generated HTML. As you saw, that's not going to work.

    Whatever the URI of &c:import> action returns must be appropriate to embed in the generated HTML at the point of the action.
     
    I can't beleive you just said that. Now I need to calm down with this tiny ad:
    We need your help - Coderanch server fundraiser
    https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
    reply
      Bookmark Topic Watch Topic
    • New Topic