error:javax.servlet.ServletException: java.sql.SQLException: Illegal operation on emp
--------------------------------------------------------------------------------
Hi,
I am stuck here about 2-hours. Kindly help me.
In this my updateuser.jsp page I am retrieving the data from drop down list which is in my search user.jsp . I am taking form name of searchuser.jsp page for reference here which is form1. in my user table there is column userid, emailed, password:
Now here I am trying to display the data about the user selected from drop down list in searchuser.jsp
Here is an my updateuser.jsp:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language ="java" %>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
String form=request.getParameter("form1");//name of previous drop down list menu
InitialContext context = new InitialContext();
DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mynewdatabase");
Connection conn = ds.getConnection();
context.close();
Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select emailid,password from user where emailid='"+form+"'");
rs.next();
[B]String EMAIL = rs.getString("emailid");[/B]
String PASSWORD = rs.getString("password");
rs.close();
%>
<table border="1">
<thead>
<tr>
<th><b>MODIFY USER</b></th>
</tr>
</thead>
<tbody>
<tr>
<td>E-MAIL</td>
<td><input type="text" name="email" value="<%=rs.getString("EMAIL")%>" size="30" /> </td>
</tr>
<tr>
<td>PASSWORD</td>
<td><input type="text" name="password" value="<%=rs.getString("PASSWORD")%>" /></td>
</tr>
<tr>
<td><input type="submit" value="SUBMIT" name="submit" /></td>
<td><input type="reset" value="RESET" name="res" /></td>
</tr>
</tbody>
</table>
</body>
</html>
But the error shows at marked line as:
javax.servlet.ServletException: java.sql.SQLException: Illegal operation on empty result set.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
Whether I am trying in the right way?
Any suggestion is highly appreciated
Thanks and Regards
Haresh