JSP Hit Counter Free Open Code
This counter uses MS SQL Server to store hits. I have used a custom stored procedure to add and display hit. This is a very good example using stored procedures with JSP. You may use this script only with MS SQL. First you should create a table and a procedure. You may use Query Manager. if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[counter]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) CREATE TABLE [dbo].[counter] ( if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[webcounter]') and OBJECTPROPERTY(id, N'IsProcedure') = 1) SET QUOTED_IDENTIFIER OFF CREATE PROCEDURE dbo.webcounter Now you can create our script. You may put this code anywhere you want to display the counter : <%@ page import="java.sql.*" %> Statement stmtt = ocon.createStatement();
drop table [dbo].[counter]
GO
[hit] [int] NOT NULL
) ON [PRIMARY]
GO
INSERT [dbo].[counter] (hit) VALUES (1)
GO
drop procedure [dbo].[webcounter]
GO
GO
SET ANSI_NULLS OFF
GO
AS
BEGIN
SET NOCOUNT ON
DECLARE @hits INT
update counter set hit = hit + 1
SELECT hit from counter
END
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
<%
Connection ocon = null;
Class.forName("com.inet.tds.TdsDriver").newInstance();
ocon = DriverManager.getConnection("jdbc:inetdae7:localhost", "sa", "");
ocon.setCatalog( "dotnet" );
ResultSet rc = stmtt.executeQuery("EXEC dbo.webcounter");
rc.next();
int pages = rc.getInt(1);
out.println("Hits : " + pages + "<br>");
%>
I have used i-net MERLIA JDBC driver.
- ASP Chat Box
- Working with Array Remove An Item
- ASPNET Web Counter Free Open Source Code
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Delete Files Online in ASP
- Video Interview With Roman Strobl
- Custom Paging in ASP Fast And Easy
- Displaying Records From An Excel Database
- Paging Results in PHP
- How to write and use a JavaBean My frst java bean
- Installing Sun Java System Application Server 9.1 in Solaris Zones
- Java SE 6 Performance White Paper
- Converting sceonds to hours minutes and seconds
- Encoding URL strings
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- What is Ecommerce and the Importance of Ecommerce
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- Counting records in PHP mySQL
- ActiveNews Manager Freeware News Exchange Software
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Easy Download Manager Free Version
- ASP Chat Box
- Writing Form Data to Text Files
- Paging Records in JSP
- Beginning-Ajax-and-ASPNET-35
- How to upload images to mySQL within PHP
- Simple XML RSS Parser
- ActiveNews Manager Freeware News Exchange Software
- Counting records in PHP mySQL
- How to write and use a JavaBean My frst java bean
- Paging Results in PHP
- Free User Registration Form
- A-timesaver-control-GridView
- ASPNET Web Counter Free Open Source Code
- Comparing Dates