• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending a value using hyperlink to another form

 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i am trying to crate a table and make one field of table(say NAME) as hyperlink. whenever we click it the value must pass onto another page. but value on another page is null. what is the reason? here is the code ...

<%@ page language="java" import="java.sql.*"%>
<%
String n;
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/j002","root","sr");
PreparedStatement st=con.prepareStatement("select * from pro");
ResultSet rs=st.executeQuery();%>
<html>
<body>
<form>
<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width=50%>
<%
while(rs.next())
{%>

<tr>
<td>
<a href="new.jsp"?n=<%= rs.getString("name")%>><%= rs.getString("name")%></a>
</td>
<td>
<%= rs.getString("no")%>
</td></tr>
<%}%>
</table>
</form>
</body></html>
 
Naveen Mishra
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sachin,
Can U shwow-up ur code of "new.jsp" ?
it seems tobe okay from this page .
 
sachin yadav
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Naveen Mishra:
Hi Sachin,
Can U shwow-up ur code of "new.jsp" ?
it seems tobe okay from this page .


<%@ page language="java" import="java.sql.*"%>
<%
session.setAttribute("x",n);
String a=(String)session.getAttribute("x");
out.println(a);
%>

or if even without session if i use
String a=request.getParameter("n")
itz not workin.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks like your quoting is off:


Try:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic