Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet JSP Servlet Search and Edit

Have Programming Question? Ask it here!
 
 
 


john
JSP Servlet Search and Edit
2 Answer(s)      4 years ago
Posted in : JSP-Servlet


Hi,

I want to thank the people who took the time and made the effort to respond to my 2 questions posted, truly ROSEINDIA and its employees are very helpful and responsive and understand developer's needs.

This is a follow up to the HTML Form in-place editing(Previous Post). The code works fine when I've incorporated it in my web application, its really an excellent way of editing a form. I just have a few adjustments if any of you could help me, I'd really appreciate it.

1. The window.open(http:///...) I want to be able to open a page instead of a window for the editing which opens in the same location. Can you please show me how that can be achieved?

2. Also, your example suggests a customer id as the basis of editing. I have tired it for other String(char) columns as well and date columns, it works to some extent but not completely. It will highlight the rows but the editing page comes out empty for some reason its not excepting date/char columns to be passed to the following jsp. Also, when I use it for a character column, if the backend table column has more than one word in the table for example the mouse over and click will not distinguish when there are 2 words with a space in the middle(meaning it works for single word highlighting). Can you tell me if I can use the character columns or date columns as the basis of editing instead of the customer id? because there is such a need in my application

3. Last thing I wanted to know if you have an example, where you can do the similar thing with javascript, what I want to achieve is

- user fills out a form on one page. On the SAME page there is a search which populates the search result table, On single click or double click of the row selection, it populates the SAME form for editing. I've seen it in a VB application, I was wondering if this can be achieved with javascript?

Thank you so much in advance.

Regards,

freind

Advertisement
View Answers

May 11, 2010 at 12:45 PM


Hi Friend,

You can search on the basis of any field but it should be in the form of string.

Try the following code:

1)tablepopup.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
String n=request.getParameter("name");
String address=request.getParameter("address");
String contact=request.getParameter("contactNo");
if((id!=null)&&(n!=null)&&(address!=null)&&(contact!=null)){
%>
<form action="edits.jsp">
<table border="1" >
<tr><td>Name:</td><td><input type="text" name="name" value="<%=n%>"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value="<%=address%>"></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contactNo" value="<%=contact%>"></td></tr>
<tr><td></td><td><input type=submit name="edit" value="Edit"></td></tr>
</table>
<input type="hidden" name="id" value="<%=id%>">
</form>
<%
}
else{
%>
<form action="adds.jsp">
<table border="1">
<tr><td>Name:</td><td><input type="text" name="name" value=""></td></tr>
<tr><td>Address:</td><td><input type="text" name="address" value=""></td></tr>
<tr><td>Contact No:</td><td><input type="text" name="contactNo" value=""></td></tr>
<tr><td></td><td><input type=submit name="button" value="Add"></td></tr>
</table>
</form>
<%}
%>
<style>
.c1 {background-color: white;}
.c2 {background-color: white;}
.c3 {background-color: red;}
</style>
<script>
function ov(i){
document.getElementById(i).className="c3";
}
function ot(i,c){
document.getElementById(i).className=c;
}
function click(id){
alert(id);
window.location.replace('http://localhost:8080/examples/jsp/popup.jsp?id='+id,'mywindow','width=500, height=350,toolbar=no,resizable=yes,menubar=yes');
}
</script>
</head>
<form>
Search:<input type="text" name="customer"><input type=submit value="Search">
</form>
<%
String name=request.getParameter("customer");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
Statement st = con.createStatement();
ResultSet rs=st.executeQuery("select * from client where name='"+name+"'");
%>
<table id="table" border="1">
<%
while(rs.next()){
%>
<tr id=<%=rs.getString("id")%> class=c1 onclick='click(<%=rs.getString("id")%>)' onmouseover='ov("<%=rs.getString("id")%>")' onmouseout='ot("<%=rs.getString("id")%>","c1")'><td><%=rs.getString("name")%></td><td><%=rs.getString("address")%></td><td><%=rs.getString("contactNo")%></td></tr>
<%
}%>
</table>
</html>


May 11, 2010 at 12:46 PM


continue..

2)popup.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
String query = "select * from client where id='"+id+"'";
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<form action="edits.jsp">
<table border="1">
<%
String name="",add="",contact="",ide="";
while(rs.next()){
name=rs.getString("name");
add=rs.getString("address");
contact=rs.getString("contactNo");
ide=rs.getString("id");
}
response.sendRedirect("tablepopup.jsp?id="+ide+"&&name="+name+"&&contactNo="+contact+"&&address="+add);
%>

3)adds.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
String query = "select * from client where id='"+id+"'";
Statement st = con.createStatement();
String name=request.getParameter("name");
String address=request.getParameter("address");
String contactNo=request.getParameter("contactNo");
int i=st.executeUpdate("insert into client(name,address,contactNo) values('"+name+"','"+address+"','"+contactNo+"')");
out.println("Data is inserted successfully");
%>

4)edits.jsp:

<%@page import="java.sql.*"%>
<%
String id=request.getParameter("id");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root","root";);
String query = "select * from client where id='"+id+"'";
Statement st = con.createStatement();
String name=request.getParameter("name");
String address=request.getParameter("address");
String contactNo=request.getParameter("contactNo");
int i=st.executeUpdate("update client set name='"+name+"',address='"+address+"',contactNo='"+contactNo+"' where id='"+id+"'");
out.println("Data is updated successfully");
%>

Thanks


Related Tutorials/Questions & Answers:
JSP Servlet Search and Edit - JSP-Servlet
JSP Servlet Search and Edit  Hi, I want to thank the people who... to the following jsp. Also, when I use it for a character column, if the backend table... there is a search which populates the search result table, On single click
edit database using jsp and servlet
edit database using jsp and servlet  I am creating a website using jsp and servlets that is used to view houses from a database. I want to be able to edit the information of each house. showAll.jsp shows all the houses and beside
Advertisements
search feature - JSP-Servlet
search feature  i need help to do a search feature servlet to search for employees from the database. the search will be done by search by employee name, department and email  Hi friend, As per your problem
Block edit menu option - JSP-Servlet
Block edit menu option  I am doing a jsp project. I have to control number of characters in a text area upto a limit. How can i block pasting through edit menu and pasting through short cut key [ctrl+v
Lucene Search in JSP - JSP-Servlet
Lucene Search in JSP  Hello Sir, I want to Develop lucene - Search engine in Jsp page which can Search full text from XML file..through XML parser.. Example: in Search interface there are one textbox after putting some value
JSP search engine - JSP-Servlet
JSP search engine  Hi! In my project i have a concept of search engine which has to search in google and display the results in my page. My PM told me use GOOGLE API for search engine. I am developing applicatin in JSP. Can
in order to create jsp and servlet code to add,delete,edit,list of persons in eclipsejavaee
in order to create jsp and servlet code to add,delete,edit,list of persons in eclipsejavaee  in order to create jsp and servlet code what all files we need to create in eclipse --dynamic web project
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
edit values of database using jsp
edit values of database using jsp  hi i want a code to edit the row from tye database and display in a page which containd radio buttons and drop down boxes using jsp code
Source Code for Implementing Search Feature in JSP using Java action/Servlet - JSP-Servlet
Source Code for Implementing Search Feature in JSP using Java action/Servlet  How do I write the source code to implement search feature in JSP using Java action/servlet? My query is: SELECT @rownum:=@rownum+1 'rownum', X
Advance Search in Servlet
this problem. Please provide me with the necessary coding. I'm using servlet and JSP...Advance Search in Servlet  Sir, I have built an application where.... the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
this problem. Please provide me with the necessary coding. I'm using servlet and JSP...Advance Search in Servlet  Sir, I have built an application where.... the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
this problem. Please provide me with the necessary coding. I'm using servlet and JSP...Advance Search in Servlet  Sir, I have built an application where.... the string typed in is "With regards to the correction in pay" later on in the search
Advance Search in Servlet
this problem. Please provide me with the necessary coding. I'm using servlet and JSP...Advance Search in Servlet  Sir, I have built an application where.... the string typed in is "With regards to the correction in pay" later on in the search
Search operation in JSP page
Search operation in JSP page  How to perform search in jsp with MYSQL database plz help me
Source Code for Implementing Search Feature in JSP using Java Action/Servlet - JSP-Interview Questions
Source Code for Implementing Search Feature in JSP using Java Action/Servlet  How do I write the source code to implement search feature in JSP using Java action/servlet? (java action is the priority, but servlet is OK) My
insert , edit , and delete button in one jsp page
insert , edit , and delete button in one jsp page  hello I want to ask about the way of creating a jsp page contains insert , edit , and delete buttons and manipulate data in database directly. any help please or hints
Source Code for Implementing Search Feature in JSF/JSP using Servlet - Java Beginners
Source Code for Implementing Search Feature in JSF/JSP using Servlet  How do I write the source code to implement search feature in JSF/JSP using Servlet?? Please advice using the example data below:- Thank You!! Employee
Search Page in jsp
Search Page in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
Search page form in jsp
Search page form in jsp  search form in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
search form in jsp
search form in jsp  search page in jsp   Please go through the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to delete this information in table when click on delete button and save
Delete and edit data in xml file using JSP
Delete and edit data in xml file using JSP   I want to know how to delete and edit data from an XML file by use of JSP. I have XML file having tasks... in the xml file,I want to delete and edit some tasks using task id then how can i do
jsp :how to edit table of data displayed using jsp when clicked on edit button
jsp :how to edit table of data displayed using jsp when clicked on edit button  i have a jsp program which displays data in the form of table ..now i want to edit this information in table when clicked on edit button and save
input type dialog box take text and search a list and focus that text - JSP-Servlet
input type dialog box take text and search a list and focus that text  i have a button..when i press it will prompt a dialog box with a text box... then it will search a list which contains data in the same page and if found
jsp and servlet
submit button,edit button and delete button,through which we can acces the data edit the data and delete the data,using jsp and servlet...jsp and servlet  I want to create a login form,which have many fields
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?
create,edit and delete in JSP using struts and SQL server2005 as database in jdeveloper?  I have a project ie create an application for users to create,edit and delete tasks: taskid, taskname, date, project in JSP and struts
jsp/servlet - JSP-Servlet
jsp/servlet  Hello ! How can we call a servlet on a link on html page like a href="servletname"> Call Servlet Is it possible?   Hi friend, I am sending simple application using servlet. This is form
search functionality using jsp from database
search functionality using jsp from database  search functionality using jsp from database
JSP-Servlet - JSP-Servlet
JSP-Servlet   how to pass the value or parameter from jsp page to servlet and view the passed value.   Hi Friend, Please visit the following links: http://www.roseindia.net/tutorial/servlet/passParameters.html
jsp/servlet - JSP-Servlet
jsp/servlet  How to create and save the excel file on given location using jsp/servlet?  hi Geetanjali, Read for more information, http://www.roseindia.net/jsp/poi/excelPOI.shtml Thanks
Searching for Code - JSP-Servlet
JSP, Servlet Searching for Code  Hi, i am looking for a jsp servlet code examples for the search function in my application.Thanks
servlet and jsp
servlet and jsp  how to connect an jsp and an servlet without connecting to database
jsp and servlet
jsp and servlet  what is the difference between jsp and servlet ? what is the advantages and disadvantages of jsp and servlet
Servlet - JSP-Servlet
Servlet and Java Code  Example and source code in Servlet and JSP
servlet and jsp - JSP-Servlet
servlet and jsp  can any one give me jsp-servlet related project-its urgent- 1-chat application 2-bug tracking system 3-online shopping 4-online...://www.roseindia.net/jsp/bank.shtml Thanks
How to edit values in textboxes from database using jsp
How to edit values in textboxes from database using jsp  Hi RoseIndia, I need help to solve my technical problem, i want to edit values in textboxes from database table using jsp, here is my code Please can anyone help me
JSP - JSP-Servlet
JSP & Servlet Example Code  Need example of JSP & Servlet
Servlet - JSP - JSP-Servlet
Servlet - JSP  Here is my complete code. all my code is running with out any error. the for loop in servlet is running as many times as my checkboxes... Servlet Code: ---------------------- package com.servlet; import
Servlet-JSP population - JSP-Servlet
Servlet-JSP population  Hi, this is regarding my previous question... let me know how to edit my code. Servlet ------------ package com.servlet... and display in the next page. I changed my servlet code something like this but i
servlet/jsp - JSP-Servlet
servlet/jsp  hi, get me the source code to upload all file formats in servlet/jsp plaese help me as soon as possible its urgent!!! by saravanan.k  Hi friend, Code to help in solving the problem
search an element in arraylist and display in jsp page
search an element in arraylist and display in jsp page  Hello Can anyone help how to take input from user from a jsp page to search for a substing in arraylist in java class and display the list in jsp page Thanks
Servlet - JSP - JSP-Servlet
Servlet - JSP  i used arraylist in servlet as shown ArrayList total = new ArrayList (); ... total.add(k[i]); session.setAttribute("efg",total); when I code this like in my jsp <%ArrayList<Integer> data= new
servlet and jsp - JSP-Servlet
servlet and jsp  Hello folks, I am very new JDBC. I am doing a project on java messaging service on the part of the project we are using JDBC. In my...   write in the jsp form action="path of servlet" and wirite
SEARCH
SEARCH  how can we do search in jsp...? option for search criteria like name and DOB...   Please visit the following links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/servlets/search.shtml
servlet and jsp - JSP-Servlet
servlet and jsp  Hi friend, please show one sample program, how to connect jsp and servlet using backend a ms-access.  Hi friend,<%@ page language="java" import="java.sql.*,java.util.*,java.text.*"
Advertisements
 

 

 

DMCA.com