how can i do it...

[nobr]I've a JSP page where I have taken the search name and printed the search name on that page like this...

<input type="submit" name="Submit" value="Submit" />

<%

String v="";

v=request.getParameter("search");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection("jdbc:odbc:test");

PreparedStatement stateSearch ;

ResultSet rsSearch;

stateSearch=con.prepareStatement("select * from tab1 where name = '"+v+"'");

rsSearch=stateSearch.executeQuery();

boolean rsSearch_isEmpty = !rsSearch.next();

boolean rsSearch_hasData = !rsSearch_isEmpty;

if(!rsSearch)

{

stateSearch=con.prepareStatement("select * from tab1 where name like '"+v+"*'");

rsSearch=stateSearch.executeQuery();

}

while(rsSearch_hasData){

Object var=rsSearch.getObject("name");

String x=var.toString();

String[] y=new String[100];

int k=0;

y[k]=new String(x);

%>

<a href="data.jsp" > ><%=x%></a>

<%

rsSearch_hasData=rsSearch.next();

}

rsSearch.close();

rsSearch = stateSearch.executeQuery();

rsSearch_hasData = rsSearch.next();

rsSearch_isEmpty = !rsSearch_hasData;

........

So the search may result into a lot of results and I'm taking each of them as hyperlink as shown above and I want when the user clicks on that link the value of the link is passed only to the "data.jsp" page.

How can I do it?[/nobr]

[1571 byte] By [gredbulla] at [2007-10-3 6:43:23]
# 1

Not sure if I quite understand. It looks like you are selecting some names from a table called tab1 using a value from the request called "v". Once you get your result set of names you are printing them out as a series of href links.

Are you asking how to pass the name to data.jsp? If so you can pass the name through the URL.

<a href="data.jsp?name=<%=x %>"><%=x %></a>

In data.jsp you can do the following to get the name value.

String name = request.getParameter("name");

slenzia at 2007-7-15 1:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thank u very much that's what I want........
gredbulla at 2007-7-15 1:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
remember that if your name contains weird characters and symbols you might have to url encode the string before you pass it through the url.
slenzia at 2007-7-15 1:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
but there's a problem now .... when I'm again using that variable to access the database again in data.jsp it's giving error "Invalid Cursor error"That may be since I'm not closing the recordset or connection
gredbulla at 2007-7-15 1:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
thank u slenzi I've got the answer and fixed the problem too....
gredbulla at 2007-7-15 1:32:45 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...