jquery ui datepicker example
<!DOCTYPE html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<%@ page import="java.awt.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import ="org.jfree.data.general.*"%>
<html>
<head>
<title>Web Expertese</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link href="newcss.css" rel="stylesheet" type="text/css"/>
<link href="jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="jquery-datepicker.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$( "#start" ).datepicker({ dateFormat: 'yy-mm-dd' });
$( "#end" ).datepicker({ dateFormat: 'yy-mm-dd' });
$("#chart").click(function(){
$.ajax({
type: "post",
url: "buildreport1.jsp", //this is my servlet
data: {
input: $('#start').val(),
output: $('#end').val()
},
success: function(response){
alert('hi');
$('#output').html(response);
}
});
});
});
</script>
</head>
<body class="aaa">
<div class="header">
<div class="main">
<div class="imagehdr">
<div class="khisak"><h1 align="right">Inventory Management System</h1></div>
</div>
<div class="menu">
<table width="100%">
<tr>
<td><table width="80%" align="center">
<tr>
<td align="center" class="font"><a href="sales.jsp">Sales</a></td>
<td align="center" class="font"><a href="brandlist.jsp">Brand-List</a></td>
<td align="center" class="font"><a href="productlist.jsp">Product-List</a></td>
<td align="center" class="font"><a href="inventory.jsp" class="font">Inventory</a></td>
<td align="center" class="font"><a href="customer.jsp" class="font">Customer Report</a></td>
<td align="center" class="font"><a href="inventoryreport.jsp" class="font">Inventory Report</a></td>
<td align="center" class="font"><a href="report1.jsp" class="font">Sales Report</a></td>
<td align="center" class="font">Expenses Report</td>
<td align="center" class="font">Profit Report</td>
<td align="center" class="font">Others</td>
</tr>
</table></td>
</tr>
</table>
</div>
</div>
</div>
<div>
</div>
<div class="right1">
<table>
<tr>
<td>From Date</td>
<td>
<input type="text" name="startdate" id="start" />
</td>
<td>To</td>
<td>
<input type="text" name="enddate" id="end" />
</td>
</tr>
<tr>
<td>
<input type="button" value="Chart" id="chart"/>
</td>
<td></td>
</tr>
</table>
</div>
<div id="output">
</div>
</body>
</html>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<%@ page import="java.awt.*" %>
<%@ page import="java.io.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.entity.*" %>
<%@ page import ="org.jfree.data.general.*"%>
<html>
<head>
<title>Web Expertese</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<link href="newcss.css" rel="stylesheet" type="text/css"/>
<link href="jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery-ui.js"></script>
<script type="text/javascript" src="jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="jquery-datepicker.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$( "#start" ).datepicker({ dateFormat: 'yy-mm-dd' });
$( "#end" ).datepicker({ dateFormat: 'yy-mm-dd' });
$("#chart").click(function(){
$.ajax({
type: "post",
url: "buildreport1.jsp", //this is my servlet
data: {
input: $('#start').val(),
output: $('#end').val()
},
success: function(response){
alert('hi');
$('#output').html(response);
}
});
});
});
</script>
</head>
<body class="aaa">
<div class="header">
<div class="main">
<div class="imagehdr">
<div class="khisak"><h1 align="right">Inventory Management System</h1></div>
</div>
<div class="menu">
<table width="100%">
<tr>
<td><table width="80%" align="center">
<tr>
<td align="center" class="font"><a href="sales.jsp">Sales</a></td>
<td align="center" class="font"><a href="brandlist.jsp">Brand-List</a></td>
<td align="center" class="font"><a href="productlist.jsp">Product-List</a></td>
<td align="center" class="font"><a href="inventory.jsp" class="font">Inventory</a></td>
<td align="center" class="font"><a href="customer.jsp" class="font">Customer Report</a></td>
<td align="center" class="font"><a href="inventoryreport.jsp" class="font">Inventory Report</a></td>
<td align="center" class="font"><a href="report1.jsp" class="font">Sales Report</a></td>
<td align="center" class="font">Expenses Report</td>
<td align="center" class="font">Profit Report</td>
<td align="center" class="font">Others</td>
</tr>
</table></td>
</tr>
</table>
</div>
</div>
</div>
<div>
</div>
<div class="right1">
<table>
<tr>
<td>From Date</td>
<td>
<input type="text" name="startdate" id="start" />
</td>
<td>To</td>
<td>
<input type="text" name="enddate" id="end" />
</td>
</tr>
<tr>
<td>
<input type="button" value="Chart" id="chart"/>
</td>
<td></td>
</tr>
</table>
</div>
<div id="output">
</div>
</body>
</html>
buildreport1.jsp
<%--
Document : buildreport1
Created on : Aug 12, 2014, 12:47:52 PM
Author : NAVJYOTI
--%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Connection"%>
<%@page import="Connect.databse"%>
<%@page import="org.jfree.chart.ChartUtilities"%>
<%@page import="java.io.File"%>
<%@page import="org.jfree.chart.entity.StandardEntityCollection"%>
<%@page import="org.jfree.chart.ChartRenderingInfo"%>
<%@page import="org.jfree.chart.JFreeChart"%>
<%@page import="org.jfree.chart.ChartFactory"%>
<%@page import="org.jfree.data.general.DefaultPieDataset"%>
<%@page import="Connect.selling"%>
<%@page import="Connect.Invent"%>
<%@page import="java.util.Iterator"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="s1" class="Connect.selling"/>
<%
String d2=request.getParameter("output");
String d1=request.getParameter("input");
System.out.println("d1 is-"+d1+"d2 is"+d2);
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link href="newcss.css" rel="stylesheet" type="text/css"/>
</head>
<body style="width: 500px;">
<div class="tabtr">
<table>
<th class="font">Product_Code</th><th class="font">Product_Name</th><th class="font">Qty_Sold</th><th class="font">Sell_Price</th><th class="font">Margin</th><th class="font">SaleByAmount</th>
<%
databse d=new databse();
Connection con=d.connectit();
java.sql.PreparedStatement pst=con.prepareStatement("SELECT Product_Code,Product_Name,Sale_Quantity as Qty_Sold,Sell_Price,Margin,SaleByAmount from sales where Bill_Date between '"+d1+"' and '"+d2+"'");
ResultSet rs=pst.executeQuery();
%>
<%
int iii=0;
while(rs.next())
{
if(iii%2==0){
%>
<tr class="trr" >
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getInt(3)%></td>
<td><%=rs.getDouble(4)%></td>
<td><%=rs.getDouble(5)%></td>
<td><%=rs.getDouble(6)%></td>
<%
}
else{
%>
<tr class="trr1" >
<td><%=rs.getString(1)%></td>
<td><%=rs.getString(2)%></td>
<td><%=rs.getInt(3)%></td>
<td><%=rs.getDouble(4)%></td>
<td><%=rs.getDouble(5)%></td>
<td><%=rs.getDouble(6)%></td>
<%}iii++;
}%>
</tr>
<div style="border: 0 solid #dddddd;
border-radius: 3px;
font-family: Tahoma,Geneva,sans-serif;
font-size: 14px;
table-layout: auto;
float: right;
table-layout: auto;
margin-right: -632px;">
<%
databse d3=new databse();
Connection con1=d3.connectit();
java.sql.PreparedStatement pst1=con1.prepareStatement("SELECT sum(Total),sum(Sale_Quantity) from sales where Bill_Date between '"+d1+"' and '"+d2+"'");
ResultSet rs1=pst1.executeQuery();
while(rs1.next())
{
final DefaultPieDataset data = new DefaultPieDataset();
data.setValue("Total", new Double(rs1.getDouble(1)));
data.setValue("Qty_Quantity", new Integer(rs1.getInt(2)));
JFreeChart chart = ChartFactory.createPieChart
("Sales Chart ", data, true, true, false);
try {
final ChartRenderingInfo info = new
ChartRenderingInfo(new StandardEntityCollection());
final File file1 = new File(getServletContext().getRealPath(".") +"/piechart.png");
ChartUtilities.saveChartAsPNG(
file1, chart, 600, 400, info);
} catch (Exception e) {
out.println(e);
}
}
%>
<IMG SRC="piechart.png" WIDTH="400" HEIGHT="400"
BORDER="0" USEMAP="#chart">
</div>
</table>
</body>
</html>