<%@ page import="java.sql.*,java.io.*,java.util.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #F6F6F6;
}
-->
</style>
<script type="text/javascript">
<!-- Begin
/***** CUSTOMIZE THESE VARIABLES *****/

// width to resize large images to
var maxWidth=100;
// height to resize large images to
var maxHeight=200;
// the id of the preview image tag
var outImage="previewField";
// what to display when the image is not valid
var defaultPic="images/asdf3rqwe.jpg";

/***** DO NOT EDIT BELOW *****/

function preview(what){
var source=what.value;
var ext=source.substring(source.lastIndexOf(".")+1,sou rce.length).toLowerCase();

globalPic=new Image();
globalPic.src=source;
setTimeout("applyChanges()",200);
}
var globalPic;
function applyChanges(){
var field=document.getElementById(outImage);
var x=parseInt(globalPic.width);
// alert(x);

var y=parseInt(globalPic.height);
if (x>maxWidth) {
y*=maxWidth/x;
x=maxWidth;
}
if (y>maxHeight) {
x*=maxHeight/y;
y=maxHeight;
}
field.src=globalPic.src;
field.width=x;
field.height=y;
}
// End -->
</script>

<link href="css/main.css" rel="stylesheet" type="text/css" />

</head>

<body>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="154" align="center" valign="bottom" background="images/topbg.gif"><table width="950" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="469">&nbsp;</td>
<td width="481">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="middle"><img src="images/log.gif" alt="logo" width="331" height="51" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
<td align="left" valign="middle" class="btnbg"><table width="450" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="8"></td>
<td height="8"></td>
<td height="8"></td>
<td height="8"></td>
<td height="8"></td>
<td></td>
<td></td>
</tr>
<tr>
<td align="center" valign="middle"><img src="images/home.gif" width="36" height="11" border="0" usemap="#Map" /></td>
<td width="1" align="center" valign="middle" background="images/vpatren.gif"></td>
<td align="center" valign="middle"><img src="images/scraps.gif" width="39" height="8" border="0" usemap="#Map2" /></td>
<td width="1" align="center" valign="middle" background="images/vpatren.gif"></td>
<td align="center" valign="middle"><img src="images/friends.gif" width="47" height="11" border="0" usemap="#Map3" /></td>
<td width="1" align="center" valign="middle" background="images/vpatren.gif"></td>
<td align="center" valign="middle"><img src="images/logout.gif" width="43" height="8" border="0" usemap="#Map4" /></td>
</tr>

</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="middle"><table width="950" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="187" align="left" valign="top" class="btnbg1"><table width="187" border="0" cellspacing="0" cellpadding="3">
<tr>
<td>&nbsp;</td>
</tr><form name="image1" action="./image" method="post">
<%
Connection connection = null;

String uname=(String)session.getAttribute("disp");
System.out.println("yyyyyyyyyyyyyyyyyyyyyyyyy"+una me);
ResultSet rs = null;
PreparedStatement psmnt = null;
InputStream sImage;


try {
Class.forName("com.mysql.jdbc.Driver").newInstance ();

connection = DriverManager.getConnection("jdbc:mysql://192.168.0.7:3306/matjava","matjava","matjava");

psmnt = connection.prepareStatement("SELECT * FROM portfolio WHERE uid = ?");
psmnt.setString(1,uname);
rs = psmnt.executeQuery();
if(rs.next()) {
Blob blob = rs.getBlob(14);
int length = (int)blob.length();

byte [] _blob = blob.getBytes(1, length);
String path="c://photo";
FileOutputStream fout=new FileOutputStream(path);
fout.write(_blob);
//response.getOutputStream().write(_blob);





%>



<tr>

<td align="left" valign="middle"><img alt="Selected Pic will preview here" id="previewField" src="<%=path%>" width="100" height="100" hspace="15" /></td>
</tr>
<%
}

}

catch(Exception ex){
out.println("error :"+ex);
}
finally {
// close all the connections.
rs.close();
psmnt.close();
connection.close();
}
%>


<tr>
<td height="10" align="center" valign="middle"></td>
</tr>
<tr>
<td><input type="file" id="picField" name="imgpath" onchange="preview(this)"/></td>
</tr>
<tr>
<td align="center" valign="middle"><input type="image" src="images/sub.gif" width="93" height="21" /></td>
</tr>
</form>
<tr>
<td align="center" valign="middle" class="main5"><table width="190" border="0" cellspacing="0" cellpadding="3">
<tr>
<td width="44">&nbsp;</td>
<td width="134" align="left" valign="middle"><a href="#" class="top1">View Profile </a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="middle"><a href="images.jsp" class="top1">Photos</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="middle"><a href="#" class="top1">Scraps</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="middle"><a href="#" class="top1">Friends</a></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="middle">&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="left" valign="middle">&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
</tr>
<tr>
<td align="left" valign="middle">Invite Your Friend : </td>
</tr>
<tr>
<td width="134" align="right"><input name="textfield72" type="text" class="txtb" /></td>
</tr>
<tr align="right">


<td align="left" valign="middle"><img src="images/invite.gif" width="93" height="21" /></td>
</tr>
<tr>
<td align="center" valign="middle"><table width="200" border="0" cellpadding="0" cellspacing="0" class="main2">

</table></td>
</tr>
</table></td>
<td align="center" valign="top" bgcolor="#FFFFFF"><table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50">&nbsp;</td>
</tr>
<tr>
<td><table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td bgcolor="#D7D7D7"><table width="350" border="0" cellspacing="1" cellpadding="0">
<tr>
<td bgcolor="#FFFFFF"><table width="350" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="10" align="center" valign="middle"></td>
</tr>
<tr>
<td align="center" valign="middle" class="main4">Edit Your Profile </td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="middle"><table width="300" border="0" cellpadding="5" cellspacing="0" class="main1">
<tr>
<td width="133" align="right" valign="middle">Username:</td>
<td width="147" align="left" valign="middle"><input name="textfield" type="text" class="txtb1" /></td>
</tr>
<tr>
<td align="right" valign="middle">Password:</td>
<td align="left" valign="middle"><input name="textfield2" type="text" class="txtb1" /></td>
</tr>
<tr>
<td align="right" valign="middle">Confirm Password: </td>
<td align="left" valign="middle"><input name="textfield3" type="text" class="txtb1" /></td>
</tr>
<tr>
<td align="right" valign="middle">DOB:</td>
<td align="left" valign="middle"><input name="textfield4" type="text" class="txtb1" /></td>
</tr>
<tr>
<td align="right" valign="middle">Address:</td>
<td align="left" valign="middle"><input name="textfield5" type="text" class="txtb1" /></td>
</tr>
<tr>
<td align="right" valign="middle">E-mail Id: </td>
<td align="left" valign="middle"><input name="textfield6" type="text" class="txtb1" /></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
</tr>
<tr>
<td align="center" valign="middle"><img src="images/sub.gif" width="93" height="21" /></td>
</tr>
<tr>
<td align="center" valign="middle">&nbsp;</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td align="left" valign="middle" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td align="left" valign="middle" bgcolor="#FFFFFF"><p align="justify" class="main2">&nbsp;</p>

<div align="justify"></div></td>
</tr>
<tr>
<td align="center" valign="middle" bgcolor="#FFFFFF">&nbsp;</td>
</tr>
<tr>
<td height="60" align="center" valign="middle" bgcolor="#202427" class="main3">Copyrights @ 2009 Social Networking System </td>
</tr>
</table>

<map name="Map" id="Map">
<area shape="rect" coords="1,2,39,10" href="#" />
</map>

<map name="Map2" id="Map2"><area shape="rect" coords="2,0,41,9" href="#" /></map>
<map name="Map3" id="Map3"><area shape="rect" coords="-2,1,45,20" href="#" /></map>
<map name="Map4" id="Map4"><area shape="rect" coords="-1,1,42,16" href="#" /></map></body>
</html>
this script is not work in diffrent browsers