This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes sending a value using hyperlink to another form Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "sending a value using hyperlink to another form" Watch "sending a value using hyperlink to another form" New topic
Author

sending a value using hyperlink to another form

sachin yadav
Ranch Hand

Joined: Nov 24, 2005
Posts: 156
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

Joined: Nov 20, 2005
Posts: 75
Hi Sachin,
Can U shwow-up ur code of "new.jsp" ?
it seems tobe okay from this page .
sachin yadav
Ranch Hand

Joined: Nov 24, 2005
Posts: 156
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

Joined: Dec 11, 2004
Posts: 13410

Looks like your quoting is off:


Try:


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sending a value using hyperlink to another form