Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8516161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:20:50+00:00 2026-06-11T05:20:50+00:00

I have seen several examples of using a Servlet to dynamically generate a chart

  • 0

I have seen several examples of using a Servlet to dynamically generate a chart using JFreeChart, and subsequently including that image in a JSP using an img tag. For example:

<img src="/MyChartServlet" width="400" height="300" border="0" alt="" />

My servlet which generates the image using JFreeChart works great, and I can see the image if I call it directly in the browser as in:

http:/myurl/MyChartServlet?id=274

The problem is that my JSP does not display the image. In fact, the JSP is not even invoking the servlet. I know this because I do not see the debug entries in the log that appear when the servlet is called.

In the Servlet I am using the JFreeChart ChartUtilities.writeChartAsJPEG() method to write the image to the output stream of the response, because I do not want to write the image to disk. As mentioned the servlet works fine when called directly.

What am I missing? Or is there a better way to do this? Maybe a plain old object can generate the chart and I can include that in the JSP? Any help would be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T05:20:52+00:00Added an answer on June 11, 2026 at 5:20 am

    You’re going about it the right way. You may be having some kind of relative path issue from the context you’re in. Try

    <img src="http://<full path to your servlet>" ...
    

    Also, you have a ?id=274 in your example, but not in your img src. If that’s required, put that in there as well.

    If you posted your servlet code, that could help, but also make sure you have your content type set properly in your servlet

    response.setContentType("image/jpeg");  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen several examples using <a href=<spring:url value='/about/' /> >About </a> I try
I have seen several examples of how to compare in Linq using the Except
I have seen several apps that make use of a UISplitViewController inside a tab.
Where is the TickCount() call? I have seen several threads on the web that
What does the Linux /proc/meminfo Mapped topic mean? I have seen several one-liners that
I've seen several examples of many to many relationships in EF using code-first, but
I have seen several execution plan examples and they displayed Nonclustered Index Insert Showplan
Recalling this post enumerating several problems of using singletons and having seen several examples
I have seen several questions with people asking about the same problem but none
I have seen several places in stackoverflow where folks have elegantly and easily turned

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.