473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

please help me

83
Hi
i have the html page to connect the jsp.

<html>
<body>
<form id="form1" name="form1" method="post" action="http://localhost:8080/admin/Example.jsp">
<textarea name="textarea" cols="" rows=""></textarea>
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
in this how to match the text field with jsp page. for example in text field i enter the table select option the corresponding table will be displayed.

In jsp i wrote the code that will diplay the content of the particular table. but my problem is how to match it.
the jsp code is

<%@ page import="java.sql.*" %>
<%
//String connectionURL = ("jdbc:mysql://localhost:3306/test";user="root";password="icc");
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>

<html><body>

<%
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "index");
statement = connection.createStatement();
rs = statement.executeQuery("select * from profit");
while (rs.next()) {
out.println(rs.getString("name")+"<br>");
out.println(rs.getString("id")+"<br>");
out.println("inserted" +"<br>");

}

rs.close();
%>

in the html text filed i enter select * from profit the above code is executed otherwise not excuted.
please give me your advice
Thanks in advance

Sang.
Oct 5 '06 #1
5 1510
r035198x
13,262 8TB
Hi
i have the html page to connect the jsp.

<html>
<body>
<form id="form1" name="form1" method="post" action="http://localhost:8080/admin/Example.jsp">
<textarea name="textarea" cols="" rows=""></textarea>
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>
in this how to match the text field with jsp page. for example in text field i enter the table select option the corresponding table will be displayed.

In jsp i wrote the code that will diplay the content of the particular table. but my problem is how to match it.
the jsp code is

<%@ page import="java.sql.*" %>
<%
//String connectionURL = ("jdbc:mysql://localhost:3306/test";user="root";password="icc");
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
%>

<html><body>

<%
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "index");
statement = connection.createStatement();
rs = statement.executeQuery("select * from profit");
while (rs.next()) {
out.println(rs.getString("name")+"<br>");
out.println(rs.getString("id")+"<br>");
out.println("inserted" +"<br>");

}

rs.close();
%>

in the html text filed i enter select * from profit the above code is executed otherwise not excuted.
please give me your advice
Thanks in advance

Sang.
In the jsp do
Expand|Select|Wrap|Line Numbers
  1. String theSql = request.getParameter("textarea");
the use theSql to conduct the query
Oct 5 '06 #2
sang
83
Thankyou for your reply

the above code is executed with my jsp program. I have another doubt in the same.That is my jsp program is execute for one table only,but i want execute all the tables in my database with same method.

That is through the html. in the text field(html) i will enter the any of the table in mydatabase that is excuted in the output.

please give your advice,
Thanks
Sang.
Oct 5 '06 #3
r035198x
13,262 8TB
Thankyou for your reply

the above code is executed with my jsp program. I have another doubt in the same.That is my jsp program is execute for one table only,but i want execute all the tables in my database with same method.

That is through the html. in the text field(html) i will enter the any of the table in mydatabase that is excuted in the output.

please give your advice,
Thanks
Sang.
Now that the sql is being input in a form, any querry for any table in the database can be input as long as it is valid sql.
Oct 5 '06 #4
sang
83
Thankyou very much for your reply.

I am not understand that sql is being input in the form. pls give in detail.

the path of sql is given to the form (ie installation path or not) i am totaly confused pls give in detail

Thankyou
Sang
Oct 6 '06 #5
r035198x
13,262 8TB
Thankyou very much for your reply.

I am not understand that sql is being input in the form. pls give in detail.

the path of sql is given to the form (ie installation path or not) i am totaly confused pls give in detail

Thankyou
Sang
Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.sql.*" %>
  2. <%
  3. //String connectionURL = ("jdbc:mysql://localhost:3306/test";user="root";password="icc");
  4. Connection connection = null;
  5. Statement statement = null;
  6. ResultSet rs = null;
  7. %>
  8.  
  9. <html><body>
  10.  
  11. <%
  12. String theSql = request.getParameter("textarea");//Get the sql from the form
  13. Class.forName("com.mysql.jdbc.Driver").newInstance();
  14. connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "index");
  15. statement = connection.createStatement();
  16. rs = statement.executeQuery(theSql);//******This is the beautiful part*****
  17. while (rs.next()) {
  18. out.println(rs.getString("name")+"<br>");
  19. out.println(rs.getString("id")+"<br>");
  20. out.println("inserted" +"<br>");
  21.  
  22. }
  23.  
  24. rs.close();
  25. %>
If you write valid sql statements in the form they
will be executed in the jsp as you input them.
The statements are coming from the user and not hardcoded into the program.
If you want to connect to anotherTable you simply type "select * from ANOTHERTABLE" in the textarea
an the jsp will get this and put in the variable theSql.
This will then be used to perform the database querry or update
Oct 6 '06 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Numberwhun | last post by:
Hello everyone! I am trying to learn java and have run into kind of a snag. Here is the code that I have so far: ------ <begin_code> ---------- import javax.swing.*; import...
1
by: HolaGoogle | last post by:
Hi all, Please help me with the following..it's realy urgent and i tried everything i could and i can't get it work properly!! Thanks in advance. Here's what i'm trying to accomplish: in my...
0
by: s_erez | last post by:
Hi, This is a realy tricky one. I have an ASP.NET application where some pages are reading data from a DB and presenting reports. In order for the user to wait while the page is reading data from...
2
by: rked | last post by:
I get nameSPAN1 is undefined when I place cursor in comments box.. <%@ LANGUAGE="VBScript" %> <% DIM ipAddress ipAddress=Request.Servervariables("REMOTE_HOST") %> <html> <head> <meta...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: pshindle | last post by:
DB2 Team - I just downloaded and unzipped the new Fixpack 9 for DB2 ESE V8 for Windows (FP9_WR21350_ESE.exe). I then burned the unzipped Fixpack files to a CD. I proceded to install this...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
PEB
by: PEB | last post by:
POSTING GUIDELINES Please follow these guidelines when posting questions Post your question in a relevant forum Do NOT PM questions to individual experts - This is not fair on them and...
4
by: fatboySudsy | last post by:
Hi, I have constructed a client program that has given me some error codes that i just cannot see. I was wondering if a different set of eyes with much more experience than me could help me out. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.