This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSP
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: sending a value using hyperlink to another form
 
Similar Threads
inserting data to a table
servlets/jsp
javax. servlet. Servlet Exception: java. sql. SQLException
reading data from jsp page to another jsp page using request.getParameter
error showing while retrieving the data from drop down list