Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

abhishek rawat

Greenhorn
+ Follow
since Mar 25, 2011
abhishek likes ...
Hibernate jQuery Netbeans IDE
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by abhishek rawat

Hi All,

I tried to save my applet on the server machine using robot method and it is working properly



But the issue here is..it is capturing whole screen ..instead of just applet...Please let me know if there is another way of saving applet .
8 years ago
But you guys have any idea ..How I will call the above file in jsp?..which extends application frame...
8 years ago
But you guys have any idea ..How I will call the above file in jsp?
8 years ago
@ Tim... I got what you were trying to say .. it should extend Applet to be a applet.
8 years ago
"The code you posted is not an applet, so you would have had to rewrite it."

Sorry but could you please explain me why this is not applet. I am using third party API(jfreechart) to show bar and pie in applet.

8 years ago
I even tried the <applet> tag but it is not loading in the browser, I searched Internet and used all the way but no success:(. Could you please help me, if possible a sample JSP calling this applet will be much appreciated.
8 years ago
Thanks for the reply!!!.... I first created the applet and it ran succesfuly. The issue is now I want to embedded applet in jsp . I know that we can call applet using this tab <applet code="MyApplet.class" width=100 height=140></applet> . BUt problem here is I have to run the applet from backend to keep updating this .class file (I think so) . But I want that it automatically gets updated when anybody calls this jsp using URL and he gets the latest data in applet form.


8 years ago
I tried little more and created below jsp. but it is just keep on loading not showing any result... any help on optimizing this jsp Or let me know if this code is correct and it will show an applet on the browser.

<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import= "javax.swing.*" %>
<%@ page import= "java.awt.*" %>
<%@ page import="java.awt.image.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import="org.jfree.chart.labels.*" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.category.*" %>
<%@ page import="org.jfree.chart.urls.*" %>
<%@ page import="org.jfree.data.category.*" %>
<%@ page import="org.jfree.data.general.*" %>
<%@ page import= "org.jfree.chart.title.TextTitle" %>
<%@ page import= "org.jfree.data.general.DefaultPieDataset" %>
<%@ page import="org.jfree.ui.*" %>

<html>
<head>
</head>
<body>
<%
ResultSet rs = null;
Connection con =null;
Statement st=null;
try
{
String queryactive1 = null;
String queryactive2= null;
String queryactive3 = null;
String queryactive4 = null;
String queryactive5 = null;
String queryactive6 = null;
String queryactive7 = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
con= DriverManager.getConnection("jdbc:sqlserver://newine:3468;instanceName=MSSQL2005","eGActiveDB_762","eGActiveDB_762");
st = con.createStatement();

%>
<p style="text-align:center"><B><u>Pie Chart Showing Case Count</u></B></p>
<%
queryactive1="SELECT count(a.case_id)as case_count , b.owner from EGPL_CASE a Right Outer Join (Select distinct OWNER from EGPL_CASE where owner in (1047,1213)) b on b.owner =a.owner and a.when_created BETWEEN '2011-01-01 00:00:00' AND '2011-01-01 1:59:59' group by b.OWNER order by b.owner";

rs=st.executeQuery(queryactive1);
rs.absolute(2);
int ravi_case=rs.getInt("case_count");
rs.absolute(4);
int pradeep_case=rs.getInt("case_count");



%>
<%

JPanel panel = new JPanel(new GridLayout(2, 2));
DefaultPieDataset dataset = new DefaultPieDataset();
DefaultPieDataset dataset1 = new DefaultPieDataset();
dataset.setValue("January "+ravi_case, ravi_case);

dataset1.setValue("January "+pradeep_case,pradeep_case);

JFreeChart chart1 = ChartFactory.createPieChart("Ravi Case", dataset, false, false, false);
JFreeChart chart2 = ChartFactory.createPieChart("Pradeep Case", dataset1, false, false, false);

panel.add(new ChartPanel(chart1));
panel.add(new ChartPanel(chart2));
panel.setPreferredSize(new Dimension(800, 600));


%>
<p style="text-align:center"><B><u>BAr Chart</u></B></p>


<%


}
catch(Exception e)
{
String error = e.toString();
e.printStackTrace();
%>

Error is : <%=error%>
<%
}
finally{
rs = null;
st = null;
con = null;
}
%>
</body>




</html>
8 years ago
Hi,

I am creating pie chart using jfreechart , I am dynamicaly taking the values from DB and showing them in pie form. I have two java file one for database and other is for showing applet (applet class have main , which calls the DB class). All code properly works well in java. But I want these to be run through jsp. such that it get embedded in jsp. I am trying many ways but unable to do it . Could you please guide me how to move forward.

Thanks
Abhishek

Below is my applet .java file
-------------------------------------------------
package Pie_Chart;

import javax.swing.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RefineryUtilities;

public class PieChart extends ApplicationFrame
{

private Object chart;


/**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public PieChart(String title) {


super(title);

DB db = new DB();
db.dbConnect("jdbc:sqlserver://newinfomine:3468;instanceName=MSSQL2005", "eGActiveDB_762", "eGActiveDB_762" );
JPanel panel = new JPanel(new GridLayout(2, 2));
DefaultPieDataset dataset = new DefaultPieDataset();
DefaultPieDataset dataset1 = new DefaultPieDataset();
dataset.setValue("January "+DB.ravi_case, DB.ravi_case);
dataset.setValue("February "+DB.ravi_case_feb, DB.ravi_case_feb);
dataset.setValue("March "+DB.ravi_case_mar, DB.ravi_case_mar);

dataset1.setValue("January "+DB.pradeep_case, DB.pradeep_case);
dataset1.setValue("February "+DB.pradeep_case_feb, DB.pradeep_case_feb);
dataset1.setValue("March "+DB.pradeep_case_mar, DB.pradeep_case_mar);




JFreeChart chart1 = ChartFactory.createPieChart("Ravi Case", dataset, false, false, false);
JFreeChart chart2 = ChartFactory.createPieChart("Pradeep Case", dataset1, false, false, false);

panel.add(new ChartPanel(chart1));
panel.add(new ChartPanel(chart2));
panel.setPreferredSize(new Dimension(800, 600));
setContentPane(panel);



}

public static void main(String[] args)
{
PieChart demo = new PieChart("Pie Chart");
demo.setVisible(true);
}

}
8 years ago
I want that if any third person wants to see this applet instead of running the whole java application. I give him a jsp url like http:\\localhost:9001\piechart.jsp and the applet automatically popup up in the browser showing the result to him. By doing this I don’t have to give him the access of the code and he will be able to see the pie chart (taking the values dynamically, every time anybody run the jsp).


8 years ago
Hi,

I am creating pie chart using jfreechart , I am dynamicaly taking the values from DB and showing them in pie form. I have two java file one for database and other is for showing applet (applet class have main , which calls the DB class). All code properly works well in java. But I want these to be run through jsp. Could you please guide me how to move forward.

Thanks
Abhishek

Below is my applet .java file
-------------------------------------------------
package Pie_Chart;

import javax.swing.*;
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RectangleEdge;
import org.jfree.ui.RefineryUtilities;

public class PieChart extends ApplicationFrame
{

private Object chart;


/**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public PieChart(String title) {


super(title);

DB db = new DB();
db.dbConnect("jdbc:sqlserver://newinfomine:3468;instanceName=MSSQL2005", "eGActiveDB_762", "eGActiveDB_762" );
JPanel panel = new JPanel(new GridLayout(2, 2));
DefaultPieDataset dataset = new DefaultPieDataset();
DefaultPieDataset dataset1 = new DefaultPieDataset();
dataset.setValue("January "+DB.ravi_case, DB.ravi_case);
dataset.setValue("February "+DB.ravi_case_feb, DB.ravi_case_feb);
dataset.setValue("March "+DB.ravi_case_mar, DB.ravi_case_mar);

dataset1.setValue("January "+DB.pradeep_case, DB.pradeep_case);
dataset1.setValue("February "+DB.pradeep_case_feb, DB.pradeep_case_feb);
dataset1.setValue("March "+DB.pradeep_case_mar, DB.pradeep_case_mar);




JFreeChart chart1 = ChartFactory.createPieChart("Ravi Case", dataset, false, false, false);
JFreeChart chart2 = ChartFactory.createPieChart("Pradeep Case", dataset1, false, false, false);

panel.add(new ChartPanel(chart1));
panel.add(new ChartPanel(chart2));
panel.setPreferredSize(new Dimension(800, 600));
setContentPane(panel);



}

public static void main(String[] args)
{
PieChart demo = new PieChart("Pie Chart");
demo.setVisible(true);
}

}
8 years ago