• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Multiple images from a servlet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm fairly new to web application development...so my question may appear standard to some of you, but I'll appreciate some pointers in the right direction.

I need to create a page which when somebody accesses using a GET request and passing in some parameters for stock tickers would show stock charts for those companies. My initial thought is that this would be done within a JSP page from which I would call a servlet and pass in each of those stock tickers one by one (thus making multiple servlet calls). Then those images returned would be displayed somehow in the JSP. Is that how it should work?

Also, initially I will just have some static images that my servlet will pull and display. But, in a real world scenariom where would these images be generated from? Let's say I want to show a chart for the last 5 years, that chart would obviously be different today than it will be 2 years from now. So somehow this chart needs to be generated dynamically. How would this be accomplished?

Thanks.
 
Sheriff
Posts: 67746
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
Keeping in mind that a JSP is just a means to dynamically create an HTML page to be sent to the browser, how would you do this if you were writing a static HTML page?
 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look for chart generation tools first. There are plenty of them, MSN live search will help you find one. Then you can create a servlet which will use this charting tool by supplying data and then return generated image to a browser. Calling of you servlet can look like:
<img src="http://mycoolcompany/mytickerapp/myticker.jsp?ticker=NVDA&period=2yers" border="0">

When your servlet gets such request, it should take parameters, based on them request data from database, then pass the data to charting tool, get image from charting tool as byte array and return this image back to a browser. Do not forget to set content type as image/gif or other format your charting tool supports.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Tch! Image requests should be directed to a servlet. JSP have built in assumptions that they will be generating an html character stream.

Bill
 
Did you miss me? Did you miss this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic