result problem

result problem

sir,i have written program given below but that program is not giving proper output.pls help me

import java.io.*;

import javax.servlet.*; import javax.servlet.http.*; import java.sql.*;

class filedata extends HttpServlet { public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException { String name1=req.getParameter("name"); try {

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:test","",""); Statement stmt=con.createStatement(); ResultSet rs=stmt.executeQuery("select * from studentbase where name=name1");

res.setContentType("text/html"); PrintWriter pw=res.getWriter();

while(rs.next()) { pw.println(rs.getString("name")); } con.close(); } catch(ClassNotFoundException e){ } catch(SQLException e){ } } }

View Answers

November 29, 2010 at 11:56 AM

Hi Friend,

Try the following code:

1)form.jsp:

<html>
<form name="form" method="post" action="../Data">
Enter Message: <input type="text" name="name">
<input type="submit" value="submit">
</form>
</html>

2)Data.java:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Data extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        String name1=req.getParameter("name");
        System.out.println(name1);
        try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:student","","");
    Statement stmt=con.createStatement();
    ResultSet rs=stmt.executeQuery("select * from data where name='"+name1+"'");
    res.setContentType("text/html"); 
    PrintWriter pw=res.getWriter();
    while(rs.next()) {
        pw.println(rs.getString("name"));
        } 
        con.close();
        } 
        catch(ClassNotFoundException e){ }
        catch(SQLException e){
        }
        }
        }

Thanks









Related Tutorials/Questions & Answers:
result problem
result problem  sir,i have written program given below but that program is not giving proper output.pls help me import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*;ADS_TO_REPLACE_1 class
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Advertisements
select Query result display problem
select Query result display problem  Hi, String SQL_QUERY ="from Cc"; Query query = session.createQuery(SQL_QUERY); for(Iterator it=query.iterate();it.hasNext();){ Object[] row = (Object[]) it.next
display result
display result  i want a code that takes input from user through dropdown box and display the result into table.all the values regarding the user input must be displayed. i am using mysql database   hi i want study
ModuleNotFoundError: No module named 'result'
ModuleNotFoundError: No module named 'result'  Hi, My Python... 'result' How to remove the ModuleNotFoundError: No module named 'result'... to install padas library. You can install result python with following command
java.sql.SQLExceptioan: Before start of result set - JDBC
java.sql.SQLExceptioan: Before start of result set   java.sql.SQLException: Before start of result set?what do i do?   Hi Friend, It seems that there is a problem with the resultSet.next() method: It is used before
result after compilation
result after compilation  public class MainCls { public static void main(String argv) { System.out.println("My text
php problem
php problem  Hello!! I have a problem ,i want to display the data....'" LIMIT 1'; $result = mysql_query( $sql); if(! $result) { die('Could not get data: ' . mysql_error()); } while($row = mysqlfetchassoc($result, MYSQL_ASSOC
problem i coding
problem i coding  i have a problem in coding a combobox containing a number of *.java program on click one of them that program should compile and run and display the result in other window
Result=Set - Java Beginners
Result=Set  Hi Friend, Can u tell how to get the count of records. in a select operation like sqlstmt="SELECT * FROM search_log_tab WHERE... result set, first move the pointer from first record to last record and get
StringTokenizer not returning proper result
. I tried to change datatype to String still the problem persists. And when I
Result Set one to many mapping
Result Set one to many mapping  Suppose there are 5 tables... Suppose result contains single entry of One record for A, Two records for B... solution to this problem
Sort Result set
Sort Result set   I build a connect for my page with the database and then read all rows and show it in a table, I want to change the view of my data to be sorted uppon a specific column when click on the column name, so what
result analysis issue
result analysis issue  i have given 100 users in my thread group for http sampler.some threads r getting response and some threads r getting error response.the error response shown in view results tree listener is as shown below
write the result into excelsheet
write the result into excelsheet  package reader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import... the result in to the same excel file....... please help me. if username is superadmin
hide and show result in jsp
hide and show result in jsp  what codes do i have to change to make my result display if only i enter the correct value? suppose if i click search,then the result will be display at the bottom.. if not.. only the header
getting result in table dynamically - Struts
getting result in table dynamically  How do i get result in tabular format dynamically using our own tags
ModuleNotFoundError: No module named 'cdumay-result'
ModuleNotFoundError: No module named 'cdumay-result'  Hi, My... 'cdumay-result' How to remove the ModuleNotFoundError: No module named 'cdumay-result' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'result_py'
ModuleNotFoundError: No module named 'result_py'  Hi, My Python... 'result_py' How to remove the ModuleNotFoundError: No module named 'result... have to install padas library. You can install result_py python with following
ModuleNotFoundError: No module named 'result-quality'
ModuleNotFoundError: No module named 'result-quality'  Hi, My... named 'result-quality' How to remove the ModuleNotFoundError: No module named 'result-quality' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'thumbor_no_result'
ModuleNotFoundError: No module named 'thumbor_no_result'  Hi, My... named 'thumbor_no_result' How to remove the ModuleNotFoundError: No module named 'thumbor_no_result' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'typed-result'
ModuleNotFoundError: No module named 'typed-result'  Hi, My Python... 'typed-result' How to remove the ModuleNotFoundError: No module named 'typed-result' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'cdumay-result'
ModuleNotFoundError: No module named 'cdumay-result'  Hi, My... 'cdumay-result' How to remove the ModuleNotFoundError: No module named 'cdumay-result' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'deferred-result'
ModuleNotFoundError: No module named 'deferred-result'  Hi, My... named 'deferred-result' How to remove the ModuleNotFoundError: No module named 'deferred-result' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'grep-result'
ModuleNotFoundError: No module named 'grep-result'  Hi, My Python... 'grep-result' How to remove the ModuleNotFoundError: No module named 'grep-result' error? Thanks   Hi, In your python environment
problem in onlinetest...
problem in onlinetest...  hi, my code getting the problem is ,when user leave a question then the server puts error... pls help me
Result interface in Struts 2.2.1
Result interface in Struts 2.2.1 Struts Result interface is a public interface of package com.opensymphony.xwork2. It extends Serializable interface. All the known classes such as PlainTextResult, ServletRedirectResult, 
how to chech result set is null or not - Java Beginners
how to chech result set is null or not  Hi, really very thanks for fast reply.I want to know how to check whether the result set is null... in solving the problem : import java.sql.*; public class CheckResultSet
problem in validation
problem in validation  sir/madam, i m using struts-1.3.10. i m getting a problem my properties file is not found.... while i hav configuired it in struts-config.xml file, likeADS_TO_REPLACE_1 thanks n regards himanshu
javascript problem
javascript problem  hi guys My problem is that I am using radio button for yes or no but i want to do that if I press yes button then enter... enter please help me this problem
code problem - Java Beginners
code problem  Dear sir, I'm havin a problem that suppose i've got... java script j2ee j2me sql plz help me to sort out this problem. thnx   Hi Friend, Please try the following sample code to solve your problem
Display Problem
Display Problem  i am creating a small window application , i want to fetch data from ms-access(db) and want to display it on tables. what options are there to show result on table. is CSS helpfull
Php Sql Result
Php Sql Result This example illustrates how to display result on the browser and how to use the result in the php application. In this example we create a select query by using mysql_query method and stored it in the result variable
problem on strings
problem on strings  in string1 "123456 ABC DEF...",IN string2 "raveen". iwant to add string2 after 123456 in the first string based on index number.i need logic for this with out using StringBuffer concept. Thanks in advanace
Problem with loginbean.jsp
Problem with loginbean.jsp  http://www.roseindia.net/jsp/loginbean.shtml - I am getting an error in loginbean.jsp.There is some error regarding .What is hello in this? Also in this example how
A Java Program That Prints Out Result Via Printer
A Java Program That Prints Out Result Via Printer  A Java Program That Prints Out Result Through Printer Depending upon paper size , and print the calculated result on printer and save result as text file
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
compilation problem
compilation problem  struts 2.0 : i have included all 5 jars in lib folder,but its giving compilation problem that package open symphony doesnot... havenot set the build path.if this is the problem then tell me how to set
Problem with cookies
Problem with cookies  Hello All, i need jsp code for RememberMe module of login. i am facing problem with cookies. so please if any one could guide me please help and provide mme the exact code.   Please visit
problem with package
problem with package  Dear sir, i have created one java file with package com.net; and i compiled the program.it showing the .class file in " net" folder.The problem is i want to use that .class file in some other
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
database problem
database problem  I did connect my jsp page to database and it showed the result on another jsp page but i want to show the data of that field on which i click to mouse from the jsp page where all the data field has been showed
Oracle9i Problem
Oracle9i Problem  Hi I have a problem in Oracle9i .I have... the table what i created .But after closing the SQL+ ,the problem started.When i... .....;.it is saying no rows are selected.Why the problem arised in not getting the data that i
problem with session.invalidate()
problem with session.invalidate()  i stuck by a line with "session.invalidate()", after user logout also by pressing the back button of the browser user is still able to navigate to his home page and able to view the session
JScrollBar Problem...
JScrollBar Problem...  Hello Sir/mam, Can i know how to use JScrollBar to JFrame without adding any JPanel to it.. i want to add JScrollBar Directly to JFrame... Please Provide me Simple Example so i can understand
problem on php
problem on php   l have five tables and build them as forms and link between them php and database and i want to build query between them plz help me soon   PHP MySQL Tutorials
URL problem
URL problem  Hi. I have created a webpage for my project website. in that i have used frameset to split the page. Now if i click any link in the page its navigating to the another page. but the problem is here in the url its
Is AI a problem?
Is AI a problem?  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: Is AI a problem? Try... "Is AI a problem?". Also tell me which is the good training courses
Skyline Problem
is the line tracing the largest y value from any rectangle in S The Problem: Write.... Your method should solve the problem three different ways; each solution
Problem in Array
Problem in Array  Hi, Can you help me with this problem? Run a program that check if the input string contains equal number of A's and B's. Hoping for your answer.Thank you.   Here is an example that check

Ads