Tuesday, 26 February 2013

Retrieving image from database

<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%
    Connection connection = null;
    String connectionURL = "jdbc:mysql://localhost:3306/test";
    ResultSet rs = null;
    PreparedStatement psmnt = null;        
    InputStream sImage;
    try
{
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        connection = DriverManager.getConnection(connectionURL, "root", "");
        psmnt = connection.prepareStatement("SELECT imagefile FROM imageupload WHERE id = ?");
        psmnt.setString(1, "4");
        rs = psmnt.executeQuery();
   if(rs.next())
{
            byte[] bytearray = new byte[1048576];
            int size=0;
            sImage = rs.getBinaryStream(1);
            response.setContentType("image/jpeg");      
            while((size=sImage.read(bytearray))!= -1 )
            {
                response.getOutputStream().write(bytearray,0,size);
}
}
}
    catch(Exception ex)
{
out.println("error :"+ex);
    }
%>

<!-- Table Structure

CREATE TABLE `imageupload` (
`id` bigint(20) NOT NULL auto_increment,
`imagefile` blob NOT NULL,
PRIMARY KEY (`id`)
)

-->

Thursday, 21 February 2013

Hide and expand in html


<script language="javascript">
function toggle5(showHideDiv, switchImgTag)
{
        var ele = document.getElementById(showHideDiv);
        var imageEle = document.getElementById(switchImgTag);
        if(ele.style.display == "block")
{
                ele.style.display = "none";
imageEle.innerHTML = '<img src="C:/Users/Tiara/Desktop/plus.png" height=15 width=15>';
        }
        else
{
                ele.style.display = "block";
                imageEle.innerHTML = '<img src="C:/Users/Tiara/Desktop/minus.png" height=15 width=15>';
        }
}
</script>

<div id="headerDivImg">
    <div id="titleTextImg">Let's use images!</div>
    <a id="imageDivLink" href="javascript:toggle5('contentDivImg', 'imageDivLink');">
<img src="C:\Users\Tiara\Desktop\minus.png" height=15 width=15>
</a>
</div>
<div id="contentDivImg" style="display: block;">This demo uses plus and minus images for hiding and showing your div dynamically.</div>

Monday, 11 February 2013

Page redirect after a certain time in html


<html>
<head>
<meta http-equiv="refresh" content="10; URL=http://www.yahoo.com" />
<title>HTML Redirect</title>
</head>

<body>
Wait Redirecting ....
</body>
</html>

Monday, 21 January 2013

Start and stop marquee on mouse over


<html>
<marquee behavior="scroll" direction="left" onmouseover="this.stop();" onmouseout="this.start();"><a href="C:\Users\admin\Desktop\new.html">Go on... hover over me!</a></marquee>
</html>

Sunday, 23 December 2012

Decimal value check code


<script type="text/javascript" language="javascript">
function isDecimal(str){
if(isNaN(str) || str.indexOf(".")<0){
alert("Invalid");
}
else{
str=parseFloat(str);
alert(str.toFixed(2))
alert ("Entered number is decimal")
}
}

function validate(){
var dec=document.form.num.value;
if (dec == ""){
alert("Please enter.");
form.num.focus();
return false;
}
if (isDecimal(dec)==false){
num="";
form.num.focus();
return false;
}
return true;
}
</script>
<form name="form" method="post" onsubmit="return validate();">
Enter Decimal Number:<input type="text" name="num"> <input
type="submit" value="Check">
</form>

Monday, 17 December 2012

Threads in java


class Thrchild implements Runnable
{
Thread t;
Thrchild()
{
t=new Thread(this,"Demo Thread");
System.out.println("Child Name"+t);
t.start();
}
public void run()
{
try
{
for(int i=1;i<=5;i++)
{
System.out.println("-->Child thread running"+i);
t.sleep(400);
}
}
catch(Exception e)
{
System.out.println("Exception in child"+e);
}
System.out.println("Child thread Completed");
}
}
public class Thrswitch {
public static void main(String arg[])
{
Thrchild tc=new Thrchild();
try
{
for(int i=1;i<=5;i++)
{
System.out.println("Main thread running"+i);
Thread.sleep(1000);
}
}
catch(Exception e)
{
System.out.println("Exception in main"+e);
}
System.out.println("Main thread Completed");
}
}

Tuesday, 4 December 2012

Adding a google map with your html document


<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDY0kkJiTPVd2U7aTOAwhc9ySH6oHxOIYM&sensor=false">
</script>

<script>
function initialize()
{
var mapProp = {
  center:new google.maps.LatLng(51.508742,-0.120850),
  zoom:5,
  mapTypeId:google.maps.MapTypeId.ROADMAP
  };
var map=new google.maps.Map(document.getElementById("googleMap")
  ,mapProp);
}

google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>

<body>
<div id="googleMap" style="width:900px;height:780px;"></div>

</body>
</html>

Kiro - Core Features

What is Kiro Kiro is an innovative AI-powered IDE that revolutionizes software development through intelligent assistance and structured wor...