Hello,
Do you have any samples for Tomcat webserver? If not can I get one?
Thanks in advance,
Best,
Veeranna Ronad.
JSP/Servlet sample code for Tomcat
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: JSP/Servlet sample code for Tomcat
Hi Veerana,
TeeChart is useable in a servlet though we don't currently have a prepared example. We'll build one to be included with a future version. In the meantime a summary on how it could be used is shown here:
Using your IDE's servlet template to create a Servlet project, modify the doGet method of the servlet file in the following way:
This hasn't been tested yet as we'll need to prepare a server environment to test it but the underlying principle should work ok.
TeeChart is useable in a servlet though we don't currently have a prepared example. We'll build one to be included with a future version. In the meantime a summary on how it could be used is shown here:
Using your IDE's servlet template to create a Servlet project, modify the doGet method of the servlet file in the following way:
Code: Select all
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.steema.teechart.Chart;
import com.steema.teechart.styles.Line;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.ImageIO;
public class TeeChartServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException
{
Chart chart = new Chart();
//add Series and data fill routines here
Line line=new Line(chart);
line.fillSampleValues(10);
OutputStream out = response.getOutputStream();
ImageOutputStream ios = ImageIO.createImageOutputStream(out);
//Write Chart to imagestream
chart.getExport().getImage().getJPEG().save(ios);
// Set content type
response.setContentType("image/jpg");
// Set content size
response.setContentLength((int)ios.length());
// Open the output stream
OutputStream out = response.getOutputStream();
ios.close();
out.close();
}
}
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |