JSP using java

JSP using java

View Answers

September 7, 2009 at 1:23 PM

Hi Friend,

Create database table chart(id,score) and try the following code:

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.ChartFrame" %>
<%@ page import="org.jfree.chart.ChartFactory" %>
<%@ page import="org.jfree.chart.ChartUtilities" %>
<%@ page import="org.jfree.chart.JFreeChart" %>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.data.*" %>
<%@ page import="org.jfree.data.jdbc.JDBCCategoryDataset"%>

<%
String query="SELECT * from chart";
JDBCCategoryDataset dataset=new JDBCCategoryDataset("jdbc:mysql://localhost:3306/test";,
"com.mysql.jdbc.Driver","root","root");

dataset.executeQuery( query);
JFreeChart chart = ChartFactory .createBarChart3D(
"Bar Chart",
"id",
"score",
dataset,
PlotOrientation.VERTICAL,true, true, false);

try
{
File image = new File("C:\\chart.jpg");
ChartUtilities.saveChartAsJPEG(image, chart, 400, 300);
FileInputStream fileInStream=new FileInputStream(image);
ServletOutputStream outStream=response.getOutputStream();
long fileLength;
byte[] byteStream;

fileLength = image.length();
byteStream = new byte[(int)fileLength];
fileInStream.read(byteStream, 0, (int)fileLength);

response.setContentType("image/jpg");
response.setContentLength((int)fileLength);
fileInStream.close();
outStream.write(byteStream);
outStream.close();

}
catch (IOException e)
{
System.out.println("Problem in creating chart.");
}
%>

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
JSP using java - Hibernate
JSP using java  This is my part of Excal sheet code using jdbc connection. int index=1; while(rs.next... using hibernate.I am having function called displayIps() and displayvalues
Advertisements
JSP using java - Java Beginners
JSP using java  sir, In my jsp page contains 3 hyperlinks say (link1 link2 link3).I want to write some java code using servlet for each hyperlinks.how to forward JSP page to servlet.I m using 3 hyperlinks in my page.My
java using JSP - Java Beginners
java using JSP  hi...i has been created one JSp page.in this page have one links name as "Show datas in Excel format".I want to create Excel file... using postgres DB.This DB have more than 4 Rows and Columns.  Hi Friend
JSP using java - Java Beginners
JSP using java  hi, In my jsppage has Combo box(contains inpacks...). I have core java code for (inpacks,outpacks,system uptime etc... inpacks from combo box and clicking bar chart options concurrently in the jsp
Java using Jsp - Java Beginners
Java using Jsp  hi sir, 1)showExcel.jsp: Show datas in Excel... and executed in netbeans 4.1. but not work in EclipseEE.i m using Tomcat server 6 .I m included JAR file also.After executing the jsp page shows
java using jsp - Java Beginners
java using jsp  i already included those jar file into my library in eclipse.i previously send my JSP code.But it shows error like. type... org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred
JSP using java - Java Beginners
JSP using java  hi...i has been created one JSp page.in this page have one links name as "Show datas in PDF format".I want to create PDF file which containing datas(from database interaction) when i clicking that link...i m using
JSP using java - Java Beginners
JSP using java  I want to generate chart in JSP page.My bar chart code contains the following function String series1 = "bars"; dataset.addValue(Integer.parseInt(values.get(i)),series1,(String)Values1.get(i
Java using Jsp - Java Beginners
Java using Jsp  hi sir, again i m getting error like. HSSFWorkbook cannot be resolved to a type. HSSFSheet cannot be resolved to a type. HSSFRow cannot be resolved to a type I included Maximum all jar file in eclipse
Register page using servlets,jsp and java beans
Register page using servlets,jsp and java beans  i want code for register page using jsp,serlets and java beans.iam getting error for my code in java...://www.roseindia.net/jsp/user-registration-form-using-jsp.shtml Thanks
Could not able to run Java Applet in JSP using <jsp:plugin>
Could not able to run Java Applet in JSP using   I could not able to run the above example applet in the JSP. Getting class not found exception... the following links: http://www.roseindia.net/jsp/applet-jsp.shtml http
Project on mailing system using Java/JSP
Project on mailing system using Java/JSP  I am making a project on mailing system in Java/JSP. How could I display the inbox messages on the home page of user? Please tell me about how to handle these messages in database
Ajax with java(using Dojo) - JSP-Servlet
Ajax with java (using Dojo)  Hi, In In place Edit Box,when I click "save" button how can I save the data in server side i.e JSP or how can I call.... Is there a possibility for tutorial on Scriptaculous. us,for Java programmers
deploy jsp using web logic - Java Beginners
deploy jsp using web logic  Hi all, I am new in Web logic server please tell me what is the steps of writing deployee the jsp using web logic. and steps also arrange the folder its urgent
reading data using struts and jsp java
reading data using struts and jsp java  how can i read data entered by user into a textbox (jsp page) into struts action class ex emp id,so that after reading emp_id it can be read into struts action class for retrieving other
Error in using java beans - JSP-Servlet
Error in using java beans  I am getting the following error when I run the jsp code. type Exception report message description The server...: Unable to load class for JSP
Doubt in using combination of JSP page and Java class. - JSP-Servlet
Doubt in using combination of JSP page and Java class.   I've got... be disabled from clicking. How to go about doing this in a "JSP Page using a Pure Java class"? The Database table looks like this: SeatCode
online test project on java using servlets and jsp
online test project on java using servlets and jsp  as i am doing online test project on java using jsp and servlets ,,,the problem is in the code of jsp file which i have sent,...,i used next and previous buttons and used two
Is JSF using JSP?
Is JSF using JSP?  Is JSF using JSP
How to export data from jsp to excel sheet by using java
How to export data from jsp to excel sheet by using java   How to export data from jsp to excel sheet by using java
remote procedure call using java - JSP-Servlet
remote procedure call using java  what is the romote procedure call and related coding in java?  Hi Friend, The RPC (Remote Procedure...: 1. A java program invokes a method on a stub, 2. Stub invokes routines
SMS alert system using Java - JSP-Servlet
SMS alert system using Java  Respected Sir/Mam, I need to develop an SMS alert application. Scope of the application: Basically... recipients. This can be developed using any kind of componentsThanks
tree using jsp code
tree using jsp code  i want to draw a tree structure of a family hierarchy using jsp code
report generation using jsp
report generation using jsp  report generation coding using jsp
How to export web page to excel using java or jsp or servlets
How to export web page to excel using java or jsp or servlets  Hi I am trying to export web page(jsp page ) to excel using jsp or servlets. I am... errors. Please can anyone tell me how to do this using java or jsp or servlets
How to display data in jsp from dao using java beans?
How to display data in jsp from dao using java beans?  Hi I need to display data in jsp pulling from dao using java beans, Please can anyone give me the sample application with above topics. Any help would be highly appreciated
generate charts using JSP
generate charts using JSP  any one know coding for generate bar chart or pie chart using JSP
ScatterPlot using jsp
ScatterPlot using jsp  hi, can anybody provide me code for ScatterPlot using jsp. thanks
datasource in jsp using struts
datasource in jsp using struts  how to get the datasource object in jsp.datasource is configured in struts-config.xml
Using Beans in JSP. A brief introduction to JSP and Java Beans.
USING BEANS IN JSP           Java Beans Java Beans are reusable components
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
BMI by using JSP Languange
BMI by using JSP Languange  Using JSP language, create a system that calculates Body Mass Index (BMI) of users who entered their weight and height. Then, system will display all the records. Can you provide me the coding
video uploading using jsp
video uploading using jsp  how to upload a videos in web page using jsp   Hi, You can upload your video with the help of JSP file upload code. Once file is upload you can play using any video player. Get the code
Jsp using mvc - JSP-Servlet
Jsp using mvc  hi I have written using mvc2 architecture, i have written logic in java ,i want to print a message on the form stating the the values are inserted successfully.So can you tell me how i have to write the code
need a sample project using java technologies like jsp, servlets, struts
need a sample project using java technologies like jsp, servlets, struts  Hi everybody! I have learnt core java,jdbc,jsp,servlets & struts... other project with detailed explanation using the above technologies by which i
Using Scriplet in JSP - JSP-Servlet
on } IN HOME JSP ****** home.jsp **** Currently I am directly using...Using Scriplet in JSP  Hi, I need to display suitable fields in my jsp but this should be done upon suitable condition becomes true for eg
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
generate pdf using jsp
generate pdf using jsp  how do i generate a pdf using jsp that should query the data from the database and write it into a pdf and download the same
jsp using netbeans
jsp using netbeans  Code to access and manage multiple e-mail accounts on the same page.. user should be able to edit mail accounts' link as required
barcode reader using jsp
barcode reader using jsp  HI ALL, I need jsp code for barcode reader.When we scan the barcode image that barcode value will be stored in one textbox automatically. please helpe me. Regards Bhanu
Tiemsheet using jsp
Tiemsheet using jsp  Hi, I am working on creating timesheet using JSP. Can you please help me on how to create a timesheet in excel using jsp and users should fill the excel sheet and then on submitting it should uplaod excel
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do
How to upload multiple images in java(struts) using jsp?
How to upload multiple images in java(struts) using jsp?  I have jsp code college.jsp page <HTML> <head> </head> <body>... using this jsp,but i want to CollegeAction class and CollegeForm class how to do

Ads