Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

hiii

Ads

 
 

Share on Google+Share on Google+

Ragini Shukla
hiii
2 Answer(s)      8 years ago
Posted in : Java Beginners
Ads
View Answers

September 9, 2008 at 3:05 PM


Hi friend,

Please give in details and technology u have problem.


Thanks


September 9, 2008 at 4:18 PM


hello Ragini

You not mention on which technologies need Solution.
The Given code is 200% ok;
Any How I give the code below contain two jsp Page. In one you enter your data and click , it will redirect to another jsp where you got the out put.
For this You Create Project in this Structure
ProjectName
Src
com
Test2.java
WebRoot
WebINF
Lib
MySql Jar File
Web
page1.jsp
page2.jsp
Deploy this and run in browser

Here The Code

Page1.jsp

<html>
<body>
<form action="page2.jsp">
<input type="text" name="srch">
<input type="submit" value="submit">
</form>
</body>
</html>

page2.jsp

<%@ page import="com.Test2" %>
<html>
<body>
<%
String name = request.getParameter("srch");
System.out.print(name);
Test2 test2 = new Test2();
test2.setString(name);
%>
<%=test2.search()%>
</body>
</html>

Test2.java

package com;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;



public class Test2
{

private String vend_name;

public void setString(String name){
vend_name = name;
System.out.println("vendname " + vend_name);
}

public String search()
{
StringBuffer sb = new StringBuffer("");
String srch = "select name from Mytable where name LIKE '%" + vend_name + "%'";
System.out.println(srch);
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/testing";, "root", "");

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(srch);
if(!rs.next()){
sb.append("<BR><TABLE ALIGN=CENTER BGCOLOR=RED><TR>"+
"<TD ALIGN=CENTER><FONT COLOR=YELLOW SIZE=4><B>"+
"Sorry! No Record Available.</FONT></TD></TR></TABLE>");
return sb.toString();
}else{
sb.append("<TABLE BORDER BGCOLOR="+"#00b8ff"+" ALIGN=CENTER>\n");
rs = stmt.executeQuery(srch);
while(rs.next()){
sb.append("<TR ALIGN=CENTER>\n");
sb.append("<Td>" + rs.getString("name") + "</td>");
sb.append("</tr>");
}
sb.append("</table>");
return sb.toString();
}
}catch(Exception ex){
return ("<PRE> Error :"+ex.toString()+"</PRE>");
}

}
}

Thanks
Rajanikant

Ads









Related Tutorials/Questions & Answers:
Hiii...
Hiii...  How to display blinking character in html?   User blink tag to blink any string or chracter. <html> <title>Blink Text</title> <body> <blink>Welcome To Roseindia</blink>
Advertisements
Ajax type
Ajax type  hiii, Is Ajax a technology platform or is it an architectural style
JSF Internalization - Java Magazine
JSF Internalization  Hiii, please tell me How to JSF Internalization
iphone
iphone  hiii, how can we use table recursively in iphone
HEAP table
HEAP table  hiii, What is HEAP table?   hello, This type of table is stored in the memory. Speed of execution of this table is very commendable
lock on a class
lock on a class  hello, Can a lock be acquired on a class?   hiii,, Yes, a lock can be acquired on a class. This lock is acquired on the class's Class object
Implement the Serializable Interface
Implement the Serializable Interface  hii How many methods do u implement if implement the Serializable Interface?   hiii, The Serializable interface is just a "marker" interface, with no methods of its own
What is Dojo?
What is Dojo?   hiii, What is Dojo?   hi, Dojo is a third-party javascript toolkit for creating rich featured applications. Dojo is an Open Source DHTML toolkit written in JavaScript
file i/o - Java Beginners
file i/o  hiii, i have to read some integers from a text file and store them in link list.. so please can i have source code for it.?? thanks
What is ETSI ?
What is ETSI ?   hiii, What is ETSI ?   hello, ETSI stands for European Telecommunications Standards Institute. This is a non-profit organization that establishes telecommunications standards for Europe
Icon image
Icon image  hiii how can we set image on the icon by which we can launch the application???   hello, when you will save a image named icon.png then it is automatically show this image on the icon
Resource files in iphone
Resource files in iphone  hiii how can we use resource files in iphone development ???   hello, if you want to use any file in your application the first you have to added it in your resource folder .. right click
Active vibration
Active vibration  hello is it possible to active vibration from code ? if yes give me solution!!!   hiii To trigger vibration in iPhone, use System Audio Services (AudioToolbox/AudioServices.h). Call
pixel into xml - XML
pixel into xml  hiii can i store image pixels in a xml file and access easily... suggest the better way...  hi friend, 201 171 81 203 175 78 210 176 87 198
concat and append
concat and append  hello, What is the difference between concat and append?   hiii, Concat is used to add a string at the end of another string.But append() is used with String Buffer to append character sequence
string to float
string to float  hiii. how can i change my string value in float for some operation?? give me some code for this??   hello, if rate is your textfield then float FloPri = [rate.text floatValue]; the value
method inside the method??
() { System.out.println("hiii..."); } } } not getting compiled y
want help regarding a project
want help regarding a project  hiii this is hemangi and I want guidance that I am working on a project of hospital management system so I want guidance that how can i implement that in swings or with other frame work? and any
DML and DDL
DML and DDL   hiii, Explain DML,DDL.   HELLO, Data Definition Language (DDL) statements are used to define the database structure or schema. CREATE, ALTER, DROP, TRUNCATE, COMMENT, RENAME Data Manipulation Language
Serializalble and Externalizable
Serializalble and Externalizable  hello, What is the difference between Serializalble and Externalizable interface?   hiii, When you use Serializable interface, your class is serialized automatically by default
What is GSM ?
What is GSM ?  hello, What is GSM ?   hiii, The Global System for Mobile Communications (GSM) is a wireless network system that is widely used in Europe, Asia, and Australia. GSM is used at three different