How to get an Id vaue

How to get an Id vaue

Dear Sir,
Thanks for posting the answer,But my actaul problem is that when i selected a row and clickon a modify or delete etc button i have to go that page and i want that selected id value...
In form action their is a servlet action when i clickon a button it is going to 1st setAction(1,this)and soon .. method ,in that method i am setting a act value.When this page is submitted it is going to servlet their i am getting a act value and this act value is used in a switch(act),so it is fetching a respected cases.In that case i am calling a jsp by using a response.sendRedirect("./jsp/delete1.jsp"); then it sis going to that jsp where i need a id values and getting from

strId = request.getParameter("Id");

But i am getting a null values their so please help me sir...

Thanks and Regards
Harini Veerapur.
View Answers

June 17, 2010 at 5:01 PM

Hi Friend,

You can use the following code:

1)form.jsp:

<%@page import="java.sql.*"%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/test";, "root", "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("SELECT * FROM email");
%>
<form name="mesdetails" onsubmit="return setaction();" ><input type="hidden" name="act" value="" />
<table class="ContentTable" id="results">
<%
while(rs.next()){
%>
<tr>
<td align="center" valign="middle"><input type="hidden"
value="<%=rs.getString(1)%>" name="Id"><input type="radio" name="checkBox" value="<%=rs.getString(1)%>" class="inptCheck" /></td>
<td align="center" valign="middle"><%=rs.getString(2)%></td>
<td align="center" valign="middle"><%=rs.getString(3)%></td>
<td align="left" valign="middle" style="padding-left:5px;word-break:break-all">&nbsp;<a href="#" name="tip"
class="tip"><%=rs.getString(4)%><span> <%=rs.getString(4)%></span></a></td>
<td align="center" valign="middle"><a href="<%=rs.getString(5) %>" name="tip" class="tip"><%=rs.getString(5)%><span><%=rs.getString(5) %></span></a></td>
<td align="center" valign="middle"><%=rs.getString(6)%></td>
<td align="center" valign="middle"><%=rs.getString(7)%></td>
</tr>
<%

}
%>
<td colspan="2" align="center">
<input type="submit" class="inptButton" name="b" value="New" >
<input type="submit" class="inptButton" name="b" value="Modify" >
<input type="submit" class="inptButton" name="b" value="Delete">
<input type="submit" class="inptButton" name="b" value="Test Mail" >
<input type="submit" class="inptButton" name="b" value="Approved And Send To All" >
</td>
<input type="hidden" name="selectedRecord" value="true"/>
</form>
<script type="text/javascript">

var pager = new Pager('results', 10);
pager.init();
pager.showPageNav('pager', 'pageNavPosition');
pager.showPage(1);

</script>

<script type="text/javascript">
function setaction() {
var d=document.mesdetails;
var op = -1;
var ch="";
for (i=mesdetails.checkBox.length-1; i > -1; i--) {
if (mesdetails.checkBox[i].checked) {
ch = document.mesdetails.checkBox[i].value;
op = i; i = -1;
}
}
if(mesdetails.checkBox.checked){

op=i;i=-1;
}
if (op == -1) {
alert("You must select a radio button");
return false;
}
d.method="POST";
d.action="info.jsp";
d.submit();

return true;
}
</script>

2)info.jsp:

<%
String id=request.getParameter("checkBox");
String bname=request.getParameter("b");

if(bname.equals("New")){
out.println("This is button 'New' and id: "+id);
}
else if(bname.equals("Modify")){
out.println("This is button 'Modify' and id: "+id);
}
else if(bname.equals("Delete")){
out.println("This is button 'Delete' and id: "+id);
}
else if(bname.equals("Test Mail")){
out.println("This is button 'Test Mail' and id: "+id);
}
else if(bname.equals("Approved And Send To All")){
out.println("This is button 'Approved And Send To All' and id: "+id);
}

%>

Thanks









Related Tutorials/Questions & Answers:
How to get an Id vaue - JSP-Servlet
How to get an Id vaue  Dear Sir , How to get an Id value of a column when it is select ,i have to get an perticular rows Id value .I have... row i have to get a particular rows Id value.how to do this sir .I done
How to get an Id vaue - JSP-Servlet
How to get an Id vaue  Dear Sir, Thanks for posting... or delete etc button i have to go that page and i want that selected id value...("./jsp/delete1.jsp"); then it sis going to that jsp where i need a id values
Advertisements
How to get Button Id ?
How to get Button Id ?  How to get Button ID instead of its value in Servlet. (I am not using jsp right now
janusgraph get vertex id - how to get id of vertex
janusgraph get vertex id - how to get id of vertex  Hi, I want to get the ids of each Vertex. How to get id of vertex? Thanks   Hi, The id property is used to get the id of the Vertex in JanusGraph. On the graph
How many ways can we get the value of current session id?
How many ways can we get the value of current session id?  How many ways can we get the value of current session id
Get Session Id
Get Session Id      ... in understanding Get Session Id .In this example we import a package... the information of the user. The servlet include the class Get Session Id,Inside
HTML Button onclick get ID of Button
HTML Button onclick get ID of Button  How i can get the ID of HTML Button on click?? I wanted to do it using JavaScript function. Thanks
How to print UIButton id
How to print UIButton id  How to get the id of the button in the IOS application? Thanks   Hi, You can use the following code: - (IBAction)btnClicked:(id)sender { UIButton *button = (UIButton *)sender; int
Get Session Id
Get Session Id      ... the session id which was generated by the container.  HttpSession session.... There is no need to generate the unique session id. There is  no need to make
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more option add new,modify and delet employee   Please visit the following
get details of employee after enter the emp_id
get details of employee after enter the emp_id  how to get employee details after entered the emp_id from database after that we have three more option add new,modify and delet employee   Please visit the following
how make ID - Ajax
how make ID  how make a ID in eyeball chat
how to retrieve all id in elasticsearch
how to retrieve all id in elasticsearch  Hi, I am using elasticsearch to store text data and perform search. I want to get all ids in elasticsearch. how to retrieve all id in elasticsearch? Thanks   Hi, You can use
how to retrieve all id in elasticsearch
how to retrieve all id in elasticsearch  Hi, I am using elasticsearch to store text data and perform search. I want to get all ids in elasticsearch. how to retrieve all id in elasticsearch? Thanks   Hi, You can use
ID using get the databse latest value and displayed in jsp
want to get the latest value using id and displayed in that start date end date etc,... How to get latest values in my jsp page and id will be shown in url...ID using get the databse latest value and displayed in jsp  function
ID using get the databse latest value and displayed in jsp
ID using get the databse latest value and displayed in jsp   I have... in the form (it means latest values) ... how to retrive that values using ID and displayed in preview.jsp page . so technically pass the new id and display the values
cookie creation without specifying the vaue - Java Beginners
cookie creation without specifying the vaue  how do we create cookies using java servlets by just specifying the name and not providing the value for it.because my colleague said once cookie is created value will be assigned
how to validate national ID number
how to validate national ID number  hey guys, plz send me a code how to vlaidate national ID number using jtextfield. in ID num thers 9 numbers +V.the V letter is included at the end of the numbers. ex:123456789V i don knw how
Java example program to get the object's ID
Java example program to get the object's ID       java get Object id In java there is no any specific method that provides us the object's ID. But each object has its own unique
id
id  how to find date of birth and gender in id in html with the help of javascript
How to identify the radio button id and row id in a table in jsp?
How to identify the radio button id and row id in a table in jsp?   function generateid(no) {var table...; table.rows[rowCount-1].cell[no].id="r"+rowCount+"c
how to get UIView by tag
how to get UIView by tag  In IOS application how to get a view by the tag id? Thanks   Hi, You can get this with the help of the function 'viewWithTag''. Following example code is getting the UILabel object from
How to code a Product id search engine?
How to code a Product id search engine?  I always wonder how people... store(just showcasing, we don't sell) each with a specific id. I am trying to code a search box that let users search products with id. Suppose, "If an user enters
[JSP] How to pass back ID to previous page.
[JSP] How to pass back ID to previous page.  Hi experts, May I ask something. How to link a page to previous page which the content in previous page is selected from database where IDPRODUCT=". I don't know how to pass back
How to get data datagrid ?
How to get data datagrid ?  How to get data datagrid in jsp from arrayList in java? Code in java CategoryDao dao = new CategoryDao...="#FFFFFF">id_Category</font></td> <td bgcolor="#888888
how to get radio value
how to get radio value    how to retrive the option value and insert the next table pls give example
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
how to get following output
how to get following output  input 123456 output 1 2 3 4 5 6
How to get project path
How to get project path  my problem is,i have one jar file,in that one xml is their,i am adding this jar file to my project,my question is how i can open or get that xml path
How to get project path
How to get project path  my problem is,i have one jar file,in that one xml is their,i am adding this jar file to my project,my question is how i can open or get that xml path
How to get Java SDK
How to get Java SDK  Hi, I have purchased a new computer and installed windows 7. Now I have to get the Java SDK and install on my computer for developing and testing Java programs. So, can anyone tell me How to get Java SDK
How to get factorial in mysql
How to get factorial in mysql  Hi, In order to improve the speed of my queries, one in particular tries to find matches between multiple tables, I am trying to use prime numbers to speed the process, but I have been googling
How to Get this Output
How to Get this Output  1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 1 2 3 4 5 1 2 3 4 1 2 3 1 2 1   Done It public class star { public static void main(String[] args) { for(int i=1;i<=5;i
How to get the Day name
How to get the Day name  Hi, I am a beginner in Java and new to this web world as well. have a requirement to implement in my assignment project as below: We need to add the days in input date such that it create the date
How to get involved
How to get involved       Shopping cart application gives you many opportunities... Application Report bugs and request features and enhancement Get familiar
how to genrate login id and password after submitting the sign up form?
how he will get their login id nd passwrd automatically...how to genrate login id and password after submitting the sign up form?  i m working on a online voting project in that i have a user sign up form so
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
how to validate e,ail id and phne number in student form
how to validate e,ail id and phne number in student form  how to validate e,ail id and phne number in student form   Hi Friend, Visit Here Thanks
How to get a values - JSP-Servlet
How to get a values  Dear sir, I have a one form... getting a null value aprt from a attachmented file,so how to get a other values..."; action = "get.jsp"; name = "form"; id = "form
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
How to get the position of the comments in the pdf
How to get the position of the comments in the pdf  how to get the postion of comments, in the extracted xml, from pdf
How to use Hibernate get sessionfactory?
How to use Hibernate get sessionfactory?  Hi, How to use hibernate get sessionfactory? Thanks
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE
HOW TO DISPLAY ID IN TEXTBOX BASED ON COMBOBOX SELECTION IN A SAME PAGE  Dear sir, Am having one table called rolemaster. In that there are 2 fields... is how to get Roleid in textbox when i select Role_name from combobox in a same
how to get the checkbox value in jsp
how to get the checkbox value in jsp  how to get the checkbox value in jsp?   JSP CheckBox Example - how to get the checkbox value in jsp
how to get this xml syntx in java??????
how to get this xml syntx in java??????  how to get this xml syntx in java?????? < comp xlink:type="new" xlink:actuate="onload"/>
how to get this xml syntx in java??????
how to get this xml syntx in java??????   how to get this xml syntx in java?????? < comp xlink:type="new" xlink:actuate="onload"/>
How to get browser time zone?
How to get browser time zone?  How to get browser Time Zone and browser date using java concept
How to get Output for a Bean problem
How to get Output for a Bean problem  Hello Kindly tell me a simple Program on Bean to get the Output using JSP code
What is VPN and How to get it?
What is a VPN and How can you get it? Today, VPN is very popular among.... In this post we are going to learn What is a VPN and how you can get it for your home... as an internet gateway. How to get a VPN? There are few free VPN services
What is VPN and How to get it?
What is a VPN and How can you get it? Today, VPN is very popular among.... In this post we are going to learn What is a VPN and how you can get it for your home... as an internet gateway. How to get a VPN? There are few free VPN services

Ads