Home Answers Viewqa JSP-Servlet How to get an Id vaue

 
 


harini
How to get an Id vaue
1 Answer(s)      2 years and 11 months ago
Posted in : JSP-Servlet

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 Pages:
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
id
id  how to find date of birth and gender in id in html with the help of javascript
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 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 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
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
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
how make ID - Ajax
how make ID  how make a ID in eyeball chat
total id
total id  how to print and total my id number ..for example if my id is 0123456789 the output will look like this : 0123456789 0+1+2+3+4+5+6+7+8+9=45 help me plz
Session ID
Session ID  How can I change the session ID of the page?   ...' session ID values because it is very likely to result in the loss of the session or with people acquiring other users' data. The session ID value should be managed
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method... get String tp = request.getParameter("indegrates"). i wrote article upload servlet and get articale name, i wont to this name catgorice parametor and after
<form id=
form id  sir, <form id="reg1" action="../UploadingCtrl" method... get String tp = request.getParameter("indegrates"). i wrote article upload servlet and get articale name, i wont to this name catgorice parametor and after
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 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
id creation
id creation  CREATE TABLE mohan2 ( sno bigint(20) NOT NULL AUTO..."); } } how can write this program in jsp its working on console but in jsp it shown internal error? how to write above code in jsp please help me i
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
row_id
row_id  sir i have created a table my_table with two rows n two column with smillar name in each cell without any primary key , how can i change the first row and third column's name in sql server 2005 , kindly send me the query
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
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
JDBC: Last Inserted Id Example
JDBC: Last Inserted Id Example In this tutorial, you will learn how to find last inserted record ID using JDBC API. Getting Last Inserted ID : Last... insertion.  you can get the last inserted id by using MAX(), writing
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
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
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
php maintain session id
php maintain session id   How to maintain session ID for a user in PHP
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate
MySQL Generate AlphaNumberic Id In JSP
how to generate id in specific format in MySQL and JSP. This example explains you that how to generate alpha numeric id in MySQL and also how to fetch... for how to generate alpha numeric id in the database using MySQL as well as how we
Hibernate criteria by id.
Hibernate criteria by id.  How to display record by using criteria by id in Hibernate?   Here is an example - package...=session.createCriteria(Employee.class).add(Restrictions.eq("id", 1)); List<
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records... question is that............. i havt to get particular id of worker on selection of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box   i have fetched all records... question is that............. i havt to get particular id of worker on selection of worker name within d combo box and display that id into a text box. plz
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... question is that............. i havt to get particular id of worker on selection of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... question is that............. i havt to get particular id of worker on selection of worker name within d combo box and display that id into a text box. plz answer
how to get selected name from combo box
how to get selected name from combo box  i have fetched all records... question is that............. i havt to get particular id of worker on selection of worker name within d combo box and display that id into a text box. plz answer
Validate ID Number
Validate ID Number   How to validate South African ID Number using...   Here is a code that check whether the south African Id is valid...("Enter South African ID: "); String id=input.nextLine
validating email id
validating email id  how to validate the email id ?   <...=""; return false; } } </script> <form id="form...;tr><td>Email </td><td><input type="text" id="email" ><
how to get combo box value - JSP-Servlet
to store that id in database. how to get that value???   Hi Friend...how to get combo box value  i have created 1 servlet & 1 jsp page. in servlet page i have fired query & fetched name & its id & that i have shown
Session ID - Java Beginners
Session ID  Do we get new session id for a new domain after clicking a page link.  Hi friend, package javacode; import java.io...." + " Info TypeValue\n" + "\n" + " ID\n
How To get DgroupId while using maven.
How To get DgroupId while using maven.  Hello everyone, I read... converter ,i can't find the right "DgroupId", also i can't get how to make... project from an archetype." I can't get how to remove error by making right
how to get the values to dropdownlist from oracle database
how to get the values to dropdownlist from oracle database   <...;% } %> </select> <br> <div id...; <div id='cityname'> <select name='cityname' >
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
how to get a values from processRecord - JSP-Servlet
how to get a values from processRecord  dear sir, i have a problem in getting a values from java to jsp.Here jsp is used to read a excel sheet... a email id these values to be inserted into a CC text area so please help me sir
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go through a simple program below and give the solution for the said below one...; <jsp:useBean id="counter" scope="session" class="CounterBean" /> <
[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
Hibernate id annotation
In this section, you will learn how to do mapping of id through annotation
Printing Session Id Using Variable
Printing Session Id Using Variable  Hi, I am a learner in PHP language. Could any one guide me, how to print session Id using variable in PHP. Thanks
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  ... suggest me how can i resolve it. Exception in thread "main" org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  ... suggest me how can i resolve it. Exception in thread "main" org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator
org.hibernate.MappingException: could not instantiate id generator  ... suggest me how can i resolve it. Exception in thread "main" org.hibernate.MappingException: could not instantiate id generator

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.