I just wanted to upload the image using form in JSP, for that I have written a code, as per below code, it is not inserting in while loop. resultant Image is not getting uploaded in directory.
Can you please help to figure out the problem?
html code
<html>
<head><title>Upload page</title></head></p> <p><body>
<form action="upload_jsp.jsp" method="post" enctype="multipart/form-data" name="form1" id="form1">
<center>
<table border="2">
<tr>
<td align="center"><b>Multipale file Uploade</td>
</tr>
<tr>
<td>
Specify file: <input name="file" type="file" id="file">
<td>
</tr>
<tr>
<td>
Specify file:<input name="file" type="file" id="file">
</td>
<tr>
<td>
Specify file:<input name="file" type="file" id="file">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="Submit" value="Submit files"/>
</td>
</tr>
</table>
<center>
</form>
</body>
</html>
jsp code
<%# page import="java.util.List"%>
<%# page import="java.util.Iterator"%>
<%# page import="java.util.ResourceBundle" %>
<%# page import="java.io.File"%>
<%# page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%# page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%# page import="org.apache.commons.fileupload.*"%>
<%
String path= "C:\\Users\\gur29175\\Desktop" ;
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
} else {
String directory="";
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
}
Iterator itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
if (item.isFormField()) {
} else {
try {
String itemName = item.getName();
File savedFile = new File(path+itemName);
//File savedFile = new File("C:\\Users\\sagar\\Desktop\\JAVA Training\\code(1)\\test\\WebContent\\WEB-INF\\uploads\\"+itemName);
//File savedFile = new File(config.getServletContext ().getRealPath("/")+"uploadedFiles/"+itemName);
item.write(savedFile);
//out.println("<tr><td><b>Your file has been saved at the loaction:</b></td></tr><tr><td><b>"+config.getServletContext().getRealPath
//("/")+"uploadedFiles"+"\\"+itemName+"</td></tr>");
out.println("<tr><td><b>Your file has been saved at the loaction:</b></td></tr><tr><td><b>"+path+
("/")+"uploadedFiles"+"\\"+itemName+"</td></tr>");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
%>
This is the line of code that might be problematic, as item.getName() will return the full path where the source file is located. This might result to a malformed file path.
Try replacing:
String itemName = item.getName();
with:
String itemName = FilenameUtils.getName(item.getName());
Make sure FilenameUtils is imported:
<%# page import="org.apache.commons.io.FilenameUtils" %>
and you have commons-io.jar in your Web app libraries.
Related
I am displaying data is a jsp page from "resultset.getString("column_name")" attribute which works fine for my columns.
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%# page import="java.io.*"%>
<%# page import="java.sql.*"%>
<%# page import="java.util.*"%>
<%# page import="java.text.*"%>
<%# page import="javax.servlet.*"%>
<%# page import="javax.servlet.http.*"%>
<%# page import="javax.servlet.http.HttpSession"%>
<%# page language="java"%>
<%# page session="true"%>
<%# page import="java.sql.*"%>
<%#page import="java.sql.DriverManager"%>
<%#page import="java.sql.ResultSet"%>
<%#page import="java.sql.Statement"%>
<%#page import="java.sql.Connection"%>
<%#page import="javax.servlet.ServletOutputStream"%>
<style>
th, td {
padding: 15px;
}
</style>
<%
String id = request.getParameter("name");
String driverName = "com.mysql.jdbc.Driver";
String connectionUrl = "jdbc:mysql://localhost:3306/";
String dbName = "employee";
String userId = "root";
String password = "root";
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
String iurl1=null;
Blob employee_dp=null;
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
%>
<h2 align="center"><font><strong>Retrieve data from database in jsp</strong></font></h2>
<%
try {
connection = DriverManager.getConnection(connectionUrl + dbName, userId, password);
statement = connection.createStatement();
String sql = "SELECT * FROM employee_details where ID='" + session.getAttribute("ID") + "'";
resultSet = statement.executeQuery(sql);
while (resultSet.next()) {
%>
<table border="0" class="display" >
<tbody>
<tr>
<td>ID : </td>
<td><%=resultSet.getString("ID")%></td>
</tr>
<tr>
<td>First Name : </td>
<td><%=resultSet.getString("name")%></td>
</tr>
<tr>
<td>Last Name : </td>
<td><%=resultSet.getString("Last_Name")%></td>
</tr>
<tr>
<td>D.O.B. : </td>
<td><%=resultSet.getString("DOB")%></td>
</tr>
<tr>
<td>image : </td>
<td><img alt="Smiley face" src="<%=resultSet.getString("employee_dp") %>" width="500" height="500"/></td>
</tr>
<tr>
<td>Attach address proof </td>
<td> <input type="file" name="txtfile"> </td>
</tr>
</tbody>
</table>
<%}}
catch (Exception e) {
out.println("DB problem");
return;
}
finally {
try {
resultSet.close();
statement.close();
connection.close();
}
catch (SQLException e) {
e.printStackTrace();
}
}
%>
Here is the code for my jsp displaying page.
Driver code to this is a basic login page which redirects to my this jsp page.
I changed the code a bit and tuned it to see if my image is available or not.
I tried by just giving the direct destination under "src" tag , it worked but when i retrieve it through resultSet.getString(column_name) it shows bits of symbols.
If i use .getBlob I get a empty image box
If i use .getString I get a lot of symbols
I have a HTML file named Track.html, it contains a text box. We enter a 10 digit number and click the button to search. After validation an AJAX function is called, which sends the number to a jsp file and the input number is searched in the database, if the value is found in the database, the output should be displayed in another text box on the same HTML page(without changing the URL). But the problem is that it is not working.
To check that my jsp file is working properly, I did the following:
I'm using a form tag so in its action attribute I mentioned the jsp file and not calling the AJAX function, so after searching the input number it redirects to a new page and displays the corresponding content fetched from the database, but I want the content to be displayed on the same page.
Here is the HTML part:
<fieldset>
<form method="post">
<table cellpadding="10" cellspacing="10">
<tr>
<td><strong>Consignment Number</strong></td>
<td><input type="text" id="cons" name="cons" autofocus="true"
placeholder="Enter the 10 digit Consignment Number"
</td>
</tr>
<tr>
<td align="center"><button onclick="search()
<span>Search</span></button></td>
<td><span><input type="reset"></span></td>
</tr>
</table>
</form>
</fieldset>
<br>
<fieldset>
<table cellpadding="10" cellspacing="10">
<tr>
<td><strong>Your Package is at:</strong></td>
<td><input type="text" id="result"></td>
</tr>
</table>
</fieldset>
Here is the AJAX function:
function search() {
if (validate()) {
var cnum = document.getElementById('cons').value;
var obj1 = new XMLHttpRequest();
obj1.onreadystatechange = function () {
if ((obj1.readyState == 4) && (obj1.status == 200)) {
document.getElementById("result").value = obj1.responseText;
}
}
obj1.open("get", "Trace.jsp?cn=" + cnum, true);
obj1.send();
}
Here is the jsp code:
<%#page import="java.sql.*"%>
<%
try
{
int conum=Integer.valueOf(request.getParameter("cn"));
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/postal_info","root","*******");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from trace;");
while(rs.next())
{
int c=rs.getInt(3);
if(conum==c)
{
out.println(rs.getString(6));
}
}
}
catch(Exception e)
{
out.println(e);
}
%>
I want to have Edit and Delete button to delete DB records in one HTML page with JSP. I tried the below code. But only the first button is working ( Whichever I put on the top) and the second one is not working. Could any one help..?
<%# page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function edit(regno){
var f=document.form;
f.method="post";
f.action='edit.jsp?regno='+regno;
f.submit();
}
function delete(regno){
var f=document.form;
f.method="post";
f.action='delete.jsp?regno='+regno;
f.submit();
}
</script>
</head>
<body>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Edit</th><th>Delete</th></tr>
<%
Connection conn = null;
int sumcount=0;
Statement st;
try{
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
conn = DriverManager.getConnection("jdbc:odbc:mydb1");
String query = "select * from student";
st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr>
<td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><input type="button" name="delete" value="Delete"
onclick="delete(<%=rs.getString(1)%>);"> </td>
<td><input type="button" name="edit" value="Edit"
onclick="edit(<%=rs.getString(1)%>);"> </td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>
Demo: http://jsfiddle.net/6mGzj/
Below example works fine, you can check in console where form is sended after button is clicked.
<form method='post' id='form'>
<table>
<tr>
<td><input type='button' data-action='delete' data-regno='2' value='delete' /></td>
<td><input type='button' data-action='edit' data-regno='3' value='edit' /></td>
</tr>
</table>
</form>
var form = document.getElementById('form');
form.addEventListener('click', function(e) {
var type = e.target.getAttribute('data-action'),
regno = e.target.getAttribute('data-regno');
//console.log(type+'.jsp?regno='+regno);
form.action = type+'.jsp?regno='+regno;
form.submit();
}, false);
There is something wrong with values passed via onclick function in your code. You need to change it from
onclick="delete(<%=rs.getString(1)%>);"
to
onclick="delete('<%=rs.getString(1)%>');"
And check this regno in your javascript function by using either alert(regno); or console.log(regno);
And one more suggestion. You are using scriptlets in your jsp code. Its highly discouraged. you need to start learning JSTL and EL avoid using scriptlets. Hope this helps..
I have run into a problem where I have to display certain data that is present in the Ratings table of MYSQL depending upon the user that is logged in.
The heirarchy is as below :
login.jsp --> check.jsp --> welcome.jsp
I have to display data on Welcome.jsp depending on the user who is logged in. I am unable to get the user parameter to server as an input for the sql query that displays the user specific data. Here are my files.
login.jsp
<%--
Document : login
Created on : May 15, 2012, 10:36:24 AM
Author : Diaa
--%>
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
alert("Enter Username!");
return false;
}
if(password==""){
alert("Enter Password!");
return false;
}
return true;
}
</script>
<div align="center">
<div class='cssmenu'>
<ul>
<li class='active '><a href='index.jsp'><span>Home</span></a></li>
<li><a href='login.jsp'><span>Login</span></a></li>
<li><a href='index.jsp'><span>About</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<div align="center">
<h1>USER LOGIN</h1>
<table>
<tr><td bgcolor="#FF9900">Username:</td><td bgcolor="#33CCCC"><input type="text" name="user"></td></tr>
<tr><td bgcolor="#FF9900">Password:</td><td bgcolor="#33CCCC"><input type="password" name="pass"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</div>
check.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%#page import="java.sql.*"%>
<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/recommend","root","root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select UserID,password from Users where UserID='"+user+"' and password='"+pass+"'");
int count=0;
while(rs.next())
{
count++;
}
if(count>0)
{
out.println("welcome "+user);
response.sendRedirect("welcome.jsp?msg=welcome "+user +" logout");
session.removeAttribute("user");
}
else
{
response.sendRedirect("login.jsp?msg=Invalid Username or Password");
}
%>
welcome.jsp
<%#page contentType="text/html" pageEncoding="UTF-8"%>
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%#taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%-- Database Interaction Queries Start --%>
<% String user=(String)session.getAttribute(user); %>
<sql:setDataSource var="genretype" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/recommend"
user="root" password="root"/>
<sql:query dataSource="${genretype}" var="result">
SELECT * from Genres;
</sql:query>
<sql:query dataSource="${genretype}" var="result1">
SELECT * from Ratings where UserID = ?
<sql:param value="${user}"/>
</sql:query>
<%-- Database Interaction Queries End --%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Heading</title>
</head>
<body>
<div align="center">
<div class='cssmenu'>
<ul>
<li class='active '><a href='index.jsp'><span>Home</span></a></li>
<li><a href='login.jsp'><span>Login</span></a></li>
<li><a href='index.jsp'><span>About</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
<%String msg=request.getParameter("msg");
if(msg!=null){
%>
<label><font color="red"><%=msg%></font></label>
<%
}
%>
<h1>Sample Title</h1>
<%--For Displaying Genre List Start --%>
<div>
<div align="left" position:absolute left:1200px>
<c:forEach var="row" items="${result.rows}">
<ul id="tab_nav">
<li><c:out value="${row.GenreName}"/></li>
</ul>
</c:forEach>
</div>
<div id="box" >
<table border="1">
<c:forEach var="row" items="${result1.rows}">
<tr>
<td><c:out value="${row.Rating}"/></td>
<td><c:out value="${row.UserID}"/></td>
<td><c:out value="${row.GenreName}"/></td>
<td><c:out value="${row.MovieName}"/></td>
</tr>
</c:forEach>
</table>
</div>
</div>
</body>
</html>
Can anyone please look into this and let me know what I am missing here :( Please feel free to ask back any other information apart from the code posted.
Fingers Crossed.. Awaiting for help!!
Cheers!
You cannot append HTML to the URL parameter of your sendRedirect() method call. There could be encoding issues with it and so it may be failing:
response.sendRedirect("welcome.jsp?msg=welcome "+user +" logout");
This should simply be
response.sendRedirect("welcome.jsp?user=" + user);
with the message being constructed in the JSP as
<c:if test="${not empty user}">
<label><font color="red">Welcome ${user}</font></label><br />
logout
</c:if>
If this doesn't solve the issue please update your question with how's the application behaving. Do you see any errors? Are you logging the exceptions anywhere?
I did a sample code here for you to check out.
Here is a sample login.jsp form:
<form action="check.jsp" method="post">
<table border="0">
<tr>
<input type="text" name="user" id="user"/>
</tr>
<tr>
<input type="password" name="pass" id="pass"/>
</tr>
<td>
<input type="submit" id="submit"/>
</td>
</table>
</form>
Then,the check.jsp could look this way:
<%#page import="java.sql.*" %>
<%
Connection con;
ResultSet rs;
PreparedStatement ps;
String query;
String user = request.getParameter("user");
String pass = request.getParameter("pass");
try{
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/recommend","root","root");
query = "select userID,password from Users where userID='"+user+"' and password='"+pass+"'";
ps = con.prepareStatement(query);
//ps.setString(1,request.getParameter("user"));
//ps.setString(1,request.getParameter("pass"));
rs = ps.executeQuery();
if(rs.next()){
session.setAttribute("user", user);
%>
<jsp:forward page="welcome.jsp"/>
<%
}else{
response.sendRedirect("login.jsp");
}
}catch(Exception e){
out.println(e);
}
%>
from the code above,you can see that after the querying of the database the attribute of the user is set and also the check.jsp forward that to the welcome.jsp page with that attribute of the user that has been set,else if the user or password is Incorrect,the person is being redirected to the login.jsp page.
The welcome.jsp page looks this way:
<body>
<% String user = (String)session.getAttribute("user");%>
<% if(user == null){
response.sendRedirect("login.jsp");
}else{
out.println("Welcome "+user);
}
%>
</body>
In the welcome.jsp page,it retrieves the session attribute of the user that is logged in via the session.getAttribute() method.It then checks if the session attribute is null and then redirects back to the user,else it prints Welcome + the user.Note that the user being printed is from the session.getAttribute which is gotten from the session.setAttribute in the check.jsp,that way you are able to get the user parameter as input from the login. I hope this helps.
<%# page language="java" contentType="application/vnd.ms-excel"%>
<% response.setHeader("Content-Disposition:","attachment;filename=Sample.xls"); %>
<TABLE>
<TR><TD>2</TD></TR>
<TR><TD>3</TD></TR>
<TR><TD>5</TD></TR>
</TABLE>
How to export the JSP table in XLSX format and how to suppress the following exception
The file you are trying to open, name.ext, is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?
use this
html code
<!DOCTYPE html>
<html>
<head>
<title>tableToExcel Demo</title>
<script>
var tableToExcel = (function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})()
</script>
</head>
<body>
<h1>tableToExcel Demo</h1>
<p>Exporting the W3C Example Table</p>
<input type="button" onclick="tableToExcel('testTable', 'W3C Example Table')" value="Export to Excel">
<table id="testTable" summary="Code page support in different versions of MS Windows." rules="groups" frame="hsides" border="2"><caption>CODE-PAGE SUPPORT IN MICROSOFT WINDOWS</caption><colgroup align="center"></colgroup><colgroup align="left"></colgroup><colgroup span="2" align="center"></colgroup><colgroup span="3" align="center"></colgroup><thead valign="top"><tr><th>Code-Page<br>ID</th><th>Name</th><th>ACP</th><th>OEMCP</th><th>Windows<br>NT 3.1</th><th>Windows<br>NT 3.51</th><th>Windows<br>95</th></tr></thead><tbody><tr><td>1200</td><td style="background-color: #00f; color: #fff">Unicode (BMP of ISO/IEC-10646)</td><td></td><td></td><td>X</td><td>X</td><td>*</td></tr><tr><td>1250</td><td style="font-weight: bold">Windows 3.1 Eastern European</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td></tr><tr><td>1251</td><td>Windows 3.1 Cyrillic</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td></tr><tr><td>1252</td><td>Windows 3.1 US (ANSI)</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td></tr><tr><td>1253</td><td>Windows 3.1 Greek</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td></tr><tr><td>1254</td><td>Windows 3.1 Turkish</td><td>X</td><td></td><td>X</td><td>X</td><td>X</td></tr><tr><td>1255</td><td>Hebrew</td><td>X</td><td></td><td></td><td></td><td>X</td></tr><tr><td>1256</td><td>Arabic</td><td>X</td><td></td><td></td><td></td><td>X</td></tr><tr><td>1257</td><td>Baltic</td><td>X</td><td></td><td></td><td></td><td>X</td></tr><tr><td>1361</td><td>Korean (Johab)</td><td>X</td><td></td><td></td><td>**</td><td>X</td></tr></tbody><tbody><tr><td>437</td><td>MS-DOS United States</td><td></td><td>X</td><td>X</td><td>X</td><td>X</td></tr><tr><td>708</td><td>Arabic (ASMO 708)</td><td></td><td>X</td><td></td><td></td><td>X</td></tr><tr><td>709</td><td>Arabic (ASMO 449+, BCON V4)</td><td></td><td>X</td><td></td><td></td><td>X</td></tr><tr><td>710</td><td>Arabic (Transparent Arabic)</td><td></td><td>X</td><td></td><td></td><td>X</td></tr><tr><td>720</td><td>Arabic (Transparent ASMO)</td><td></td><td>X</td><td></td><td></td><td>X</td></tr></tbody></table>
</body>
</html>
Use this way:
<%# page import="java.sql.* " %>
<%
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=SimDetails.xls");
Connection con = null;
PreparedStatement ps=null;
ResultSet rs = null;
%>
<%# include file="directconnection.jsp"%>
<%
int simid=0;
int net=0;
String sim="";
String mob="";
String contnum="";
String couridate="";
String sendaddr="";
String networkName="";
String contpe="";
try{
%>
<table>
<tr>
<th width="5%">SNo</th>
<th width="30%;">Network</th>
<th width="30%;">Sim Number</th>
<th width="30%;">Mobile Number</th>
<th width="30%;">Sender Address</th>
<th width="30%;">Contact Person Number</th>
<th width="30%;">Contact Person Name</th>
</tr>
<%
String strSimExportQuery=" SELECT SM_SIM_ID,SM_PROVIDER_ID,SM_SIM_NUMBER,SM_MOBILE_NUMBER,"+
" SM_SENDER_ADDRESS,SM_CONTACT_PERSON_NO,SM_CONTACT_PERSON FROM RS_SIM_MASTER ";
ps=con.prepareStatement(strSimExportQuery);
rs=ps.executeQuery();
while(rs.next()){
simid++;
net=rs.getInt("SM_PROVIDER_ID");
if(net==1){
networkName="Vodafone";
}
sim=rs.getString("SM_SIM_NUMBER");
mob=rs.getString("SM_MOBILE_NUMBER");
sendaddr=rs.getString("SM_SENDER_ADDRESS");
contnum=rs.getString("SM_CONTACT_PERSON_NO");
contpe=rs.getString("SM_CONTACT_PERSON");
%>
<tr>
<td><%=simid%></td>
<td><%=networkName%></td>
<td><%=sim%></td>
<td><%=mob%></td>
<td><%=sendaddr%></td>
<td><%=contnum%></td>
<td><%=contpe%></td>
</tr>
<%}%>
</table>
<%
}catch(Exception e){
out.println(e);
}
finally {
if (rs!= null){ rs.close(); rs=null;}
if(ps!=null){ps.close();ps=null;}
if (con != null) {con.close();con = null;}
}
%>