Hi,
In my searchquestionid,
jsp page I am try to showing data of one column i.e. description available in table name
questioneid in tabular format. This page shows all
word in that is in particular column. I am Using
Form name as reference for next page i.e. updatequestionid.jsp to retrieve the all data related to that row showing in previous jsp page .but when I trying to display all field in that row I get only the first word of description column .
E.G. in searchquestionid.jsp page description column=�here is a
test page�
But updatequestionid.jsp showing the same column =�here�
Here is my searchquestionid.jsp
<blockquote>
code:
<pre name="code" class="core">
<%@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>SEARCH-QUESTION-ID</title>
</head>
<body>
<form name="searchquestion" action="questionidupdate.jsp" method="POST">
<table border="1" width="100">
<thead>
<tr>
<th>Seach Question-id</th>
</tr>
</thead>
<tbody>
<tr>
<td><b>Question-Id:</b> </td>
<td><select name="question">
<% Connection connection = null;
Statement st = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
st=con.createStatement();
try {
rs = st.executeQuery("Select * from questionid");
while (rs.next())
{
%>
<option value = "<%=rs.getString("Questionid")%>" ><%=rs.getString(2)%></option>
<%
}
}
finally
{
if (rs != null)
{
rs.close();
rs = null;
}
if (st != null)
{
st.close();
st = null;
}
}
%>
</select>
</td>
</tr>
<tr align="center">
<td><input type="submit" value="Submit" name="submit" /></td>
</tr>
</tbody>
</table>
</form>
</body>
</html> </pre>
</blockquote>
and here is updatequestionid.jsp:
<blockquote>
code:
<pre name="code" class="core">
<%@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>QUESTION-ID-UPDATE</title>
</head>
<body>
<form name="searchgroup" action="questionidupdateok.jsp" method="POST">
<table border="1">
<%
String QUESTIONID=request.getParameter("question");
try {
Connection connection = null;
Statement st = null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
st=connection.createStatement();
rs = st.executeQuery("select Questionid,Description from questionid where Questionid='"+QUESTIONID+"'");
%>
<tbody>
<tr><thead>
<tr>
<th><center>MODIFY Question-Id</center></th>
</tr>
</thead>
<td>Question-Id</td> <%
while (rs.next()) {
%>
<td><input type="text" name="id" value=<%=rs.getString("Questionid")%> size="20" /> </td>
<TR><TD>Desription</TD>
<TD><input type="text" name="descr" value=<%=rs.getString("Description")%> size="100" /></TD>
</TR>
</tr>
<tr>
<td><input type="submit" value="CHANGE" name="submit" /></td>
<td><input type="reset" value="RESET" name="res" /></td>
</tr>
</tbody>
<% } %>
<%
rs.close();
st.close();
} catch (Exception ex) {
out.println(ex.getMessage());
%>
<%
out.println("Unable to connect to database.");
}
%>
</table>
</form>
</body>
</html> </pre>
</blockquote>
Any suggestion is highly appreciated.
Thanks and regards
Harshal