AJAX Forums

please help

This is a discussion on please help within the AJAX Ideas forums, part of the General category; hello friends,i hope this forum will help me to improve ajax skills.. i am doing ibm's tgmc project for that i need to learn ajax please help.. my ...

Old 08-27-2008, 05:12 PM   #1 (permalink)
Junior Member
 
Join Date: Aug 2008
Posts: 1
Rep Power: 0 vicky_sky is on a distinguished road
please help

hello friends,i hope this forum will help me to improve ajax skills..
i am doing ibm's tgmc project for that i need to learn ajax please help..
my doubt:
i have a html page (for user login) ..
i need to fetch password from database user_master(table) accoring to the the user name specified..
i want to get the response from server without reloading the page ..(using page)..my index.html page code is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<script type="text/javascript">
var req;
function ajaxCall()
{
var url = "si.jsp";
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
req.open("POST", url, true);
req.onreadystatechange = callback;
req.send(null);
}
function callback()
{
if (req.readyState == 4)
{
document.getElementById("passwd").value=req.respon seXML.getElementsByTagName('pass')[0].firstChild.data;
}
}
</script>
<body>
<form id="form1" name="form1" method="post" >
User name
<input type="text" name="user" id="user" />
password
<input type="password" name="passwd" />
<input type="submit" name="Submit" value="Submit" onclick=ajaxCall()>
<SPAN ID="Message" bgcolor="red">
</SPAN>
</form>
</body>
</html>
-----------------------
my si.jsp page is:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%!
String pass;
%>
<%
javax.naming.InitialContext ctx= new javax.naming.InitialContext();
javax.sql.DataSource ds =(javax.sql.DataSource)ctx.lookup("java:comp/env/jdbc/prison");
java.sql.Connection con = ds.getConnection();
java.sql.Statement st = con.createStatement();
String use=request.getParameter("user");
String pas=request.getParameter("passwd");
String q="select * from prison_management.user_master" ;
java.sql.ResultSet rs = st.executeQuery(q);
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
while(rs.next())
{
if(use.equals(rs.getString("username")) && pas.equals(rs.getString("password")))
{ response.getWriter().write("<?xml version='1.0' encoding='UTF-8'?>");
response.getWriter().write("<userlog>");
response.getWriter().write("<user>"+rs.getString(" password")+"</user>");
response.getWriter().write("</userlog>");
break;
}
}
%>
</body>
</html>
-----------------------
the password is not printed in the html page..
what went wrong?please help...
vicky_sky is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes



All times are GMT -4. The time now is 08:36 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5
Copyright ©2006 - 2008, AJAXwith.com