Home Answers Viewqa JSP-Servlet inteconnecting forms

 
 


vijay sood
inteconnecting forms
1 Answer(s)      4 years and 2 months ago
Posted in : JSP-Servlet

View Answers

April 2, 2009 at 3:40 PM


Hi friend,

Following code will be helpful for you.

step1) Create a form in jsp page to enter table name.

<html>
<form name="form" action="retrieveData.jsp" method="post">
<table>
<tr><td>Enter table name:</td><td><input type="text" id="name" name="name"></td>
<tr><td><input type="submit" value="Submit"></td></tr>
</form>
</html>

step2) Now to retrieve the data of entered table name,create another jsp page.

<%@ page import="java.sql.*"%>
<%@ page import="java.io.*" %>
<html>
<head>
<title>database connectivity</title>
</head>
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement stmt=con.createStatement();
String table=request.getParameter("name");
ResultSet rs=null ;
DatabaseMetaData meta = con.getMetaData();
rs = meta.getTables(null, null, null, new String[]{"TABLE"});
String tableName=null;
while (rs.next()) {
tableName = rs.getString("TABLE_NAME");
if(table.equals(tableName)){
out.println("Table Name= "+tableName);
out.println("<br>");
String strquery = "select * from "+tableName;
rs=stmt.executeQuery(strquery);
ResultSetMetaData md=rs.getMetaData();
int col= md.getColumnCount();
for (int i=0; i<col; i++) {
out.println(md.getColumnName(i+1));
}
out.println("<br>");
while(rs.next()){
for (int i=0; i<col; i++) {
out.println(rs.getString(i+1)+"\t");
}
out.println("<br>");
}
}
}
if(table.equals("")){
out.println("Enter table");
}
else if(!table.equals(tableName)) {
out.println("Table does not exist");
}
con.close();
}
catch(SQLException e) {
out.println("exception occured" +e);
}
%>
</body>
</html>

Thanks









Related Pages:
inteconnecting forms - JSP-Servlet
inteconnecting forms  hi, i have several tables in mysql database. i am creating some forms using jsp. i want to enter the name of the table and to get the table specified in the entry box to be displayed in the output
use forms.
use forms.  How do I use forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
use tables to structure forms
use tables to structure forms  How can I use tables to structure forms
tables to structure forms
tables to structure forms  How can I use tables to structure forms
tables to structure forms
tables to structure forms  How can I use tables to structure forms
Two forms and One Servlet
Two forms and One Servlet  Dear Sir, I have 2 forms in one page and one submit button into second form which submits data to one servlet. If I do... get both forms textbox value. Thanks in advance
JAVA BEAN WITH ORACLE FORMS
JAVA BEAN WITH ORACLE FORMS  Hi..I am doing my final year Project.. I need the ste-by-step procedure to integrate a bean with oracle forms? Please help me
What are different normalization forms?
What are different normalization forms?  What are different normalization forms?   Hi, 1NF: Eliminate Repeating Groups- Make a separate table for each set of related attributes, and give each table a primary key. Each
Date forms
Date forms       In this section we are demonstrating the retrieval of date from the Date object in various forms. In the following code segment we are performing
Multiple forms in JSP - JSP-Servlet
Multiple forms in JSP   Hi, I want to place multiple submit buttons in jsp pages ! and the multiple buttons will perform multiple actions based on the click of those buttons !   function
Two forms submission to one Action Class in Struts2.0
Two forms submission to one Action Class in Struts2.0  Hi, I have two forms.I want to submit two forms with only one submit button to the same action, same method. How can i get this. Please reply me
JSP WITH MULTIPLE FORMS
JSP WITH MULTIPLE FORMS       In  this example, you will learn how to make multiple forms in single jsp page. Most of the times people need to use multiple forms
Hide show HTML forms using javascript
Hide show HTML forms using javascript  How to hide a HTML form in my application using JavaScript?   HTML Code to create checkbox <...;div id="yourDiv"> ...other forms... </div> JavaScript function to hide
HTML Forms and PHP
Here we would integrate the HTML forms and PHP by creating HTML forms to collect the user input turning that input into variables, and then doing various...;YourName." This is what ties together forms and variables - each form field can
Print Only Forms Contents - Java Beginners
Print Only Forms Contents  Hello Sir I Have Created Simple Registration Form with Database Connectivity, Now I Want To Print Registration form Contents ,How I can Do that, plz Help Me  Hi Friend, Please go through
fill out forms on web pages - JDBC
fill out forms on web pages    I want to fill out forms on web pages, it's is very important to my project. For example there is a web-site www.blauh...com , in which there wil be a form , what i hav to do is to fill that form
jsf forms - Java Server Faces Questions
jsf forms  Hi, I have some queries in jsf forms please solve it. 1.how to set the height of a table 2. how to set the image at right side. 3.how to set a table in center. 4.i need one table and one image at one row tell me
Multiple Forms in JSP
Multiple Forms in JSP          The form tag creates a form for user input. A form can contain checkboxes, textfields, radio- buttons and many more. Forms are used
The Normal Forms
The Normal Forms       The Normal Forms The database community sets the few rules or guidelines for database normalization. These rules are called as normal forms
How to use Bean Area in Oracle Forms 9i with Sample code ?
How to use Bean Area in Oracle Forms 9i with Sample code ?  Hi friend.I posted a query,but I didn't get the answer for it.Help me to resolve including a bean area in oracle forms 9i and using it in forms.Thanks in advance.Help me
online voting systems with 10 forms and 3 pages calculations
online voting systems with 10 forms and 3 pages calculations  kindly send me the online voting system and online inventory management systems used by java or html, with 10 forms and 3 validation pages, with form designing
PHP HTML forms and Post Method Code
PHP HTML forms and Post Method Code PHP html function With the given PHP HTML Code one can retrieve the form data and display the input on same page. PHP... to create html forms and display data using PHP Post Method in PHP
JSF Forms - Developing form based application
JSF Forms - Developing form based application   ... everything you need to know about JSF. Developing Forms in JSF 1.2 In this tutorial we will show you how to develop UI forms using JSF 1.2. 
'for' Loop
The for and equivalent while statements have these forms. for (init-stmt; condition; next
Spring 3.2 MVC Form Handling
In this example, you will learn about handling forms in Spring 3.2 MVC
JavaScript submit method
JavaScript submit method       We can submit forms in following two ways in an HTML page: By using submit button  Submitting form programmatically using JavaScript. 
Form and its Elements
;  In this session, we will introduce you to the idea of Forms... different types of input elements are used in HTML forms--- Text Field: Text Field..." by default. The Select Element The Select element is used in HTML forms to create
Draw a Mandelbrot
Draw a Mandelbrot       In this section, you will studied how to draw a Mandelbrot. A Mandelbrot is a collection of points in the plane whose boundary forms a fractal
The Open Source World is a Big Part of PHP
The PHP scripting language is something that can work on many types of computers and can be used alongside HTML. It is also able to work with a variety of different forms of technology. The big reason for this comes from how PHP is an open
Online Real-Time GPS Phone Tracking Service
Online Real-Time GPS Phone Tracking Service Online Real-Time GPS Phone Tracking Service is a useful service handy to track mobile phones and devices. They come in all forms and different shapes and sizes. Not only they are used
Spring 3.0 MVC Form, Spring 3.0 MVC Form Example
of Spring 3 MVC forms. After completing this tutorial you will be able to understand...;ul> <li><a href="forms/simpleForm.html">Simple...;dispatcher</servlet-name> <url-pattern>/forms/*</url-pattern>
Android Application Development is a Wide Open Process
be found in many forms. A major reason as to why this is so comes from how
Create a Sash Form
by the orientation) and places a Sash between them. In the given example, two sash forms
ZF Create Form
need to send data from one page to another through forms, in ZF we can create forms and put some text box, password type text box and other UI and at the same... how to create forms and what will be the exact coding to display a form and its
Java BigDecimal add example
Java BigDecimal add example       In this example working of .add() method is demonstrated in following two constructor forms add(BigDecimal augend) and add(BigDecimal augend
Vehicle trackings and fleet management
track that forms an integral part of management. Management includes... by tracking a vehicle. Management forms an integral part of every business
A Crossword Mobile Application Can Handle Many Games
people can enjoy crossword puzzles in a variety of different forms. Many... with it. A user can easily find different puzzles in a variety of forms. Many applications
What is a PHP File?
A PHP file includes PHP code, functions, text HTML tags and scripts that can process online forms, get the date and time, or access information from a database, such as MySQL database. A PHP file returns to the browser as a plain HTML
Types of GPS tracking devices
Types of GPS tracking devices GPS tracking devices come in all forms and different shapes and sizes. Whilst they are used on an advanced platform to track satellites and vehicles, they can also be used in households for tracking
Social media marketing - 6 myths busted
Social media marketing - 6 myths busted Social media marketing is one of the most popular forms of advertising around today. Because of this there are so many different stories and opinions that surround it and it can be a daunting
Accordion Navigator Container in Flex4
Accordion Navigator Container in Flex4: The Accordion Navigator container is used for Form navigation. You can make many Forms in a single screen and navigate from one form to another form very easily by clicking on navigation button
Open Source Books
Open Source Books Open Books O'Reilly has published a number of Open Books--books with various forms of "open" copyright--over the years. The reasons for "opening" copyright, as well as the specific license agreements
What Apps Can the iPad Use?
What Apps Can the iPad Use? The applications, or apps, that are available on the iPad are ones that come in many different forms. They are all used to get the iPad to work with a variety of different functions. These are individual
VoIP Technology
around VoIP technology in its many forms: desktop applications, telephone services
Java operator
Java operator  What is the difference between the prefix and postfix forms of the ++ operator
jsp problem - Java Server Faces Questions
jsp problem  step by step processing of bean and forms processing in jsp

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.