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



Home Answers Viewqa JSP-Interview-Questions ID using get the databse latest value and displayed in jsp

Have Programming Question? Ask it here!
 
 
 


Gowrishankar
ID using get the databse latest value and displayed in jsp
1 Answer(s)      3 years and 3 months ago
Posted in : JSP-Interview Questions


I have some text box like name address city ,I have submit button and preview button ... once click the submit button the data will be stored in mysql database ... after i click the preview button it should show the values you have entered 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 in preview jsp page. the id will shown in end of the url also..


Advertisement
View Answers

April 29, 2011 at 11:20 AM


1)form5.jsp:

<%@page import="java.sql.*"%>
<html>
<script>
function sub(){
    var name=document.form.name.value;
    var address=document.form.address.value;
    window.location.replace("insert.jsp?name="+name+"&&address="+address);
}
function pre(id){

    window.location.replace("form2.jsp?id="+id);
}
    </script>
<form name="form">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" name="address"></td></tr>
<tr><td><input type="button" value="Submit" onclick="sub();"></td>
<%
Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery("Select * from data");
int id=0;
    if(rs.last()){
id=rs.getInt("id");
System.out.println(id);
        }
%>
<td><input type="button" value="Preview" onclick="pre(<%=id%>);"></td></tr>
</table>
</html>

2)insert.jsp:

<%@page import="java.sql.*"%>
<table>
<%
String name=request.getParameter("name");
String address=request.getParameter("address");
        try{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        int i=st.executeUpdate("insert into data(name,address) values('"+name+"','"+address+"')");
        out.println("Data is successfully inserted!");
        }
        catch(Exception e){
        System.out.print(e);
        e.printStackTrace();
        }
        %>
<a href="form5.jsp">Go Back</a>

3)form2.jsp:

<%@page import="java.sql.*"%>
<%
int id= Integer.parseInt(request.getParameter("id"));

Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
        Statement st=con.createStatement();
        ResultSet rs=st.executeQuery("Select * from data where id="+id+"");
        String name="",address="";
        while(rs.next()){
            name=rs.getString("name");
            address=rs.getString("address");
        }
        System.out.println(name+address);
        %>
<html>
<form>
<table>
<tr><td>Your Name is:</td><td><input type="text" value="<%=name%>"></td></tr>
<tr><td>Your Address is:</td><td><input type="text" value="<%=address%>"></td></tr>
</table>
</form>
</html>
<a href="form5.jsp">Go Back</a>


Related Tutorials/Questions & Answers:
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
ID using get the databse latest value and displayed in jsp
ID using get the databse latest value and displayed in jsp  function... 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
Advertisements
Retrieve data from databse using where in JSP
Retrieve data from databse using where in JSP  Hi, can somebody help me? I have a jsp page. in that i want to get data from the database where username is matched. i tried it. but can't get the output. here is the code. please
how to create a bar chart in jsp by fetching value from oracle databse?
how to create a bar chart in jsp by fetching value from oracle databse?  i want to show the population of various states in a bar chart in my jsp page by fetching the data from my oracle table. i am using my eclipse as my IDE
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... a respected cases.In that case i am calling a jsp by using a response.sendRedirect
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 the error messages displayed
Get the error messages displayed  How to get the error messages displayed
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 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
sorting and filtering the displayed table data using jsp and xml
sorting and filtering the displayed table data using jsp and xml  I have created a xml file and a jsp file, which uses DOM parser to display... that is displayed in web page. How to do it ??? Please help as soon as possible
Read Excel data using JSP and update MySQL databse
Read Excel data using JSP and update MySQL databse  HOw to read excel data using JSP and update MySQl database
Getting the last inserted id using jsp
Getting the last inserted id using jsp  Pls how can i retrieve the last inserted id after submitting a form to mysql using jsp
Finding MAX value from emp_id column using SQL query?
Finding MAX value from emp_id column using SQL query?  I need to select maximum of the Emp_id values from SQL server 2005 table.I was using... of emp id from the table.(Actually it picks up Max value using by looking at 1st
get a radio button click value - JSP-Servlet
servlet from another jsp i.e 'main.jsp', then you have to store the value of id... have one probs that is i m getting a null value i m calling getParameter("id... to retrieve value of id: String id=request.getParameter("idvalue"); Hope
add text box and select list dynamically and get its value to store it into database using jsp request parameter
add text box and select list dynamically and get its value to store it into database using jsp request parameter  its very helpful when you have only dynamically added text field but want code to retrive value of dynamically
get value from multiple textbox in jsp
get value from multiple textbox in jsp  how to get multiple textbox value in another jsp? If i using the following code <%for(int i=0;i<3;i++) {%> <td>name<input type="text" class="name" id="name">
how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp
how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp  how to print data(From databse Oracle10g) in preformatted A4 and A3 paper using jsp. I am inserting analysis report into a database using
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.
How can I access databse through JSP. I am using postgresql-8.4.4-1-windows as database and jboss-4.0.5.GA as server.  I am using postgresql-8.4.4-1-windows as database, jboss-4.0.5.GA as server and jdk-6-windows-i586 with IDE
session value not get in many jsp page.
session value not get in many jsp page.  I am using servlet to set...,response); and get session value on jsp page by follwing:- String user=(String)session.getAttribute("user"); this is work but when this code is use in other jsp
Get form value in same page - JSP-Servlet
Get form value in same page  Hello friends, Can we get a form field value in the same to be processed in java coding... friend, For solving the problem visit to : http://roseindia.net/jsp/user
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...;"></td> <td><input type="hidden" name="id" value="<
how to get combo box value - JSP-Servlet
the id in servlet page, that i have associated with value i.e "> bcoz i hav 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
how to get HTTP GET request value using javascript
how to get HTTP GET request value using javascript  how to get HTTP GET request value using javascript   how is how you can get HTTP GET request value using javascript: var parameter = window.location.search.replace
list to be displayed in jsp page.
list to be displayed in jsp page.  Can any one help me? Am developing the code in struts.I have a list in action class that has to be printed in the dropdownlist in another jsp page.Please help me in the code.. Thank u
How to save and get value from JSP
How to save and get value from JSP  Employee Name Time... 324 2012-12-12 save i want to save dis value jsp to action ...how can i get all value ..and store..how can its values goes
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
how to show effect (visual) on jsp page using value from database
how to show effect (visual) on jsp page using value from database  I am making a ticket booking system. I have a databse with a clumn "booking status... as seats should be displayed red. when the value in booking status
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  For example, In Employee.jsp form, When i click employee id value in combo box ,the related employee name will be displayed in text field
get a value when a radio button clicked - JSP-Servlet
get a value when a radio button clicked  sorry sir my actual probs is that 1st i m callig a jsp in that i m displaying a table where i used a radio button to access a value(also used u r code),then in this jsp i m having a forms
core java project by using databse
core java project by using databse  hello sir, i'm a b.tech final year student.... i wantto make a project on java with database... can u plzz suggest me how i can start for it.... means on which topic i can make project
how to retrieve the id value itself from the access database to drop down listbox in jsp
how to retrieve the id value itself from the access database to drop down listbox in jsp  how to retrieves the id which is an int datatype, from... data"); while(rs.next()){ int id=rs.getInt("id"); %> <option value
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  Hi Friends, When i click combobox value in jsp form page, it will diplay related value.... I am using only this page.. not get value from another page
get a value when a radio button clicked - JSP-Servlet
get a value when a radio button clicked  Here is my code sir please...; //System.out.println("******* id in jsp login Is ******" +id); f.submit..., strMatter = null, strMatterFile = null; %> function transfer(id){ var f
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...; <td><input name="pack_id" type="type" value="<%= pack_id %>" size
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]  HI team, This is Srinivas, and I have a query and i explained here... be displayed in a webpage after click the button - 'show details'. Could you pls help me
get info from mysql using jsp and servlet
get info from mysql using jsp and servlet  HELLO! I wanna create a jsp page which able to let me get its name, phone and other info by asking the user to key in their email address from mysql database by using servlet and jsp too
retrive article from sql databse and show using php
retrive article from sql databse and show using php  hello sir i have sql database which i store articles.i want to show these article on web page using php. my field are image,title,summary,content id. plz provide me
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  How to insert check box value to the oracle database using jsp? I want to create hotel's...; <td><input name="pack_id" type="type" value
How to get the output of JSP program using Bean
How to get the output of JSP program using Bean  Hi Kindly go...; <jsp:useBean id="counter" scope="session" class="CounterBean" /> <... visit the following link: http://www.roseindia.net/jsp/using-bean-counter.shtml
get data between date using jsp with msaccess
get data between date using jsp with msaccess  hi, urgently i need program for get data between date using jsp with MsAccess database.plz any one can help me.thanks for anyone replay with regards c.b.chellappa
how to get a numeric value from a message - JSP-Servlet
how to get a numeric value from a message  dear sir, I have to get a numeric value from a following message matter i.e Dear [1... is in a text box am getting this message using //following code
How to retrieve data by using combo box value in jsp? - JSP-Servlet
How to retrieve data by using combo box value in jsp?  I am using a single jsp form.. i did not get from another form.. i do not use 2 jsp form.. all.... Note: I am using only this jsp form.. i do not use
insert data into mysql databse using swing
insert data into mysql databse using swing   Blockquote hi, here is my code, i want code for store data into mysql database when click on submit button from access data from this form, please provide code, import java.awt.
How to retreive data by using combo box value - JSP-Servlet
, i am using only one form. U are using html form and jsp form. So get...){ cid=Integer.parseInt(request.getParameter("cid")); I am using only a single jsp with html .. So i cannot use request.getParameter. If i am using null value
how to insert checkbox value into database using jsp
how to insert checkbox value into database using jsp  how to insert check box value to the database using jsp my code is <link href..." name="pmanager" value="Enter" ></td> <td align
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
delete row using id
delete row using id  package pkg2; import org.hibernate.Query; import... = "delete from Insurance insurance where id = 2"; Query query = sess.createQuery...()); } } } this is the code m using . Error is -query must begin with SELECT or FROM
How to get the output of jsp program using Bean
How to get the output of jsp program using Bean  Hello my Roseindia...; Next i created JSP program for the above one by using Bean and i opened the Tomcat webserver and clicked the JSP and i got the HTTP Status -500
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... links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp
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... links: http://www.roseindia.net/jsp/user-search.shtml http://www.roseindia.net/jsp
Advertisements
 

 

 

DMCA.com