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



Home Answers Viewqa JavaScriptQuestions jsp update request happens to be invoked by a link

Have Programming Question? Ask it here!
 
 
 


akshatha
jsp update request happens to be invoked by a link
2 Answer(s)      3 years and a month ago
Posted in : JavaScript Questions


<tr class="bg-row1">     
<td class="td-highlighted-2">      
<div align="left"><a href="<%=contextPath%>/jsp/admin/UpdateProject.jsp"><%=searchList1.getProjid()%></a></div>     
</td>     
<td class="td-highlighted-2">       
<div align="left"><%=searchList1.getProjname()%></div>     
</td>     </tr>

here jsp update request happens to be invoked by a link
in updateproject.jsp how can i refer projid and projname value in a text box


Advertisement
View Answers

March 14, 2011 at 3:36 PM


1)application.jsp:

<%@ page import="java.sql.*" %>
<html>
<head>
<script language="javascript">
function editRecord(id){
    var f=document.form;
    f.method="post";
    f.action='edit.jsp?id='+id;
    f.submit();
}
</script>
</head>
<body>

<br><br>
<form method="post" name="form">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";

int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr><td><%=rs.getString(2)%></td>
<td><%=rs.getString(3)%></td>
<td><%=rs.getString(4)%></td>
<td><%=rs.getString(5)%></td>
<td><a href="javascript:editRecord(<%=rs.getString(1)%>);">Edit </a></td>

</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
</form>
</body>
</html>

2)edit.jsp:

<%@page language="java"%>
<%@page import="java.sql.*"%>
<form method="post" action="update.jsp">
<table border="1">
<tr><th>Name</th><th>Address</th><th>Contact No</th><th>Email</th></tr>
<%
String id=request.getParameter("id");
int no=Integer.parseInt(id);
int sumcount=0;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
String query = "select * from employee where id='"+no+"'";
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next()){
%>
<tr>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="address" value="<%=rs.getString("address")%>"></td>
<td><input type="text" name="contact" value="<%=rs.getInt("contactNo")%>"></td>
<td><input type="text" name="email" value="<%=rs.getString("email")%>"></td>
<td><input type="hidden" name="id" value="<%=rs.getString(1)%>"></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Update" style="background-color:#49743D;font-weight:bold;color:#ffffff;"></td>
</tr>
<%
}
}
catch(Exception e){}
%>
</table>
</form>


March 14, 2011 at 3:37 PM


continue..

3)update.jsp:

<%@page import="java.sql.*"%>
<%
String ide=request.getParameter("id");
int num=Integer.parseInt(ide);
String name=request.getParameter("name");
String address=request.getParameter("address");
int contact=Integer.parseInt(request.getParameter("contact"));
String email=request.getParameter("email");
try{
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=null;
st=conn.createStatement();
st.executeUpdate("update employee set name='"+name+"',address='"+address+"',contactNo="+contact+",email='"+email+"' where id='"+num+"'");
response.sendRedirect("/examples/jsp/application.jsp");
}
catch(Exception e){
System.out.println(e);
}
%>


Related Tutorials/Questions & Answers:
jsp update request happens to be invoked by a link
jsp update request happens to be invoked by a link  <tr class...;%=searchList1.getProjname()%></div> </td> </tr> here jsp update request happens to be invoked by a link in updateproject.jsp how can i refer projid
Dynamic link in JSP
Dynamic link in JSP  Hii everyone...I have stuck from last 2 days... Three columns i.e. souce name, Target name and Link. and that link should be only... jsp page which contains some checkboxes, so from that checkboxes , i have
Advertisements
link tag in jsp - JSP-Servlet
link tag in jsp  Hi, how to write link in a jsp page. give me... this in jsp page it will work although it is html tag.  Visit for more information. http://roseindia.net/jsp/jspsession/SessionCount.shtml Thanks
jsp request in struts1
jsp request in struts1  how the request for a JSp is processed in Struts1?Any JsP page in the end a servlet only.where is the URL pattern for this servlet
update jsp
update jsp  <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC...;/Controller"> <center> <input type="hidden" name="page" value="update"/>
JSP Request Object
JSP Request Object  JSP Request Object ?   request object in JSP is used to get the values that the client passes to the web server during an HTTP request. The request object is used to take the value from the client?s
Request for codes - JSP-Servlet
Request for codes  Sir , I am an engineering student i am interested in learning JAVA also i need some example code for creating Registration form codes for creating web based application using JSP sir plz send me which
request object - JSP-Servlet
request object  What is Difference Between request.getHeader("x-forwarded-for") and request.getServerName() pls give me reply as soon as possible
request header and response - JSP-Servlet
request header and response  hi sir, i have facing some problem... and contain 4 buttons add,update,delete and view .On clicking on the any of the button... the following link: http://www.roseindia.net/servlets/web-application.shtml Thanks
Update delete perticular row from brower on link - Struts
Update delete perticular row from brower on link   how can update... patel 34334 mumbai update delete smita kadam 45454 new york update delete when i click on update than that perticular row are display on another
Request for Discussion forum in jsp
Request for Discussion forum in jsp  Hi i want discussion forum to my project. Can anyone tell me, what are all requirements needed to create it. THanks in advance
JSP Request Dispatcher
JSP Request Dispatcher   ... the RequestDispatcher class to transfer the current request to another jsp page. You can... page. Understand with Example The Tutorial illustrate an example from 'JSP Request
how to retrieve link - JSP-Servlet
how to retrieve link  how to retrieve link of a web page and use it as input in the program
How JSP Forwards a request
How JSP Forwards a request       In this section you will study how jsp forwards a request.  The <jsp:forward>  forwards the request information from one resource
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... exactly make a link with it   Jsp edit application 1)application.jsp...; <td><input type="submit" name="Submit" value="Update" style
how to give link from jsp to jsp page
how to give link from jsp to jsp page  hi this is my following code... exactly make a link with it   Jsp edit application 1)application.jsp...; <td><input type="submit" name="Submit" value="Update" style
JSP Request URI
JSP Request URI          JSP Request URI is used to return the URI... the request object that will return the URI of the current JSP page. Understand
link
the link the table is displayed and other links were hidden if i want to click the next link i have to refresh the page instead i want to do is when i click the link the table should display and again when i click the link the table should
Update Database from jsp
Update Database from jsp   I want to update my oracle database... UPDATE button the database field should be updated . I have a drop down menu...= null; st=conn.createStatement(); st.executeUpdate("UPDATE TEST_LINKS SET
Link from html to jsp - Development process
Link from html to jsp   Hi, Can u send me code. when i click html link button , control should go to jsp page wat i mentioned in view... Friend, To give link from html page to jsp, you have to run the jsp page.After
link
link  hey frnds can anyone plz tell me how can i store my videos as link in my database and can retrive the video using servlet by clicking on to that link .it may be confusing sorry about that and if someone can than plz help me
LINK
LINK  Thank you friend.cant we use single click instead of double click and also for four link u has given the example but i have 14 links in that case wat i should do
request header and response - JSP-Servlet
request header and response  Create aservlet that redirects a client to a.html if its morning ,to b.html if its a afternoon else to c.html.
link
link  how can we give hyperlinks on data retrieved from the database and when a particular option is clicked it should be saved in another database and details related to that link should be diaplay and stored in the database
ServletFileUpload request getInputStream - JSP-Servlet
ServletFileUpload request getInputStream  Hi All, I want multiple...(HttpServletRequest request, HttpServletResponse response) throws... = ServletFileUpload.isMultipartContent(request); if (!isMultipart) { } else { InputStreamReader
LINK
LINK  I have four links which link to a table,if i click one link... i want to ask is when i click the link the table is displayed and other links were hidden if i want to click the next link i have to refresh the page instead i
regarding-update the Jsp page itself - JSP-Servlet
regarding-update the Jsp page itself   Joined: Aug 17, 2009 Messages: 12 [Post New]posted Today 10:39:52 PM Quote Edit [Up] I have two Jsp... is i want to update the information on same Jsp page. How can I implement
request header and response - JSP-Servlet
request header and response  Create a html form that accept user name and password ,if the user name and password is admin it redirects it to adminhome.html,if the user name and password is guest and guest it redirects
Request header display in a jsp page
Request header display in a jsp page  ... to display request header information in a jsp page. When user request... to a jsp. In this example, request_header_jsp.jsp is used to display header
How to append a request parameter in a jsp page - JSP-Servlet
How to append a request parameter in a jsp page   i have a jsp page which have a some school names link. when i click to link of a school name... to attach a request parameter in a link which appended from first page so that i can
JSP/Servlet to read and update Excel
JSP/Servlet to read and update Excel  Hi Team, My requirement is based upon my input(name) value via one jsp, the program(jsp/servlet) should fetch... access to edit the values and update back to the Excel. So when the user give update
dynamic mail link creation - JSP-Servlet
dynamic mail link creation  I wanna create a dynamic link like mail opening pages ( dynamic of data that specifying use by hyperlinks ) HELP ME
Request Object In JSP
Request Object In JSP     ... to the server, is received by the HTTP request object of the JSP. To access... either in the current JSP page or the another JSP page by passing the request
update excel sheet using jsp::
update excel sheet using jsp::   Hi Sir,... I have a excel... given excel sheet and display it into another excel sheet using jsp" i am using 'session' to get the empid from one page to another jsp
update multiple rows in jsp - JSP-Servlet
update multiple rows in jsp  Hi I am trying to do a multiple row update in JSP. code as follows.. > Can you...,author and title in the database. Follow these steps to update these fields: 1
how to design a jsp page via link which will expire after 3 days if not use?
how to design a jsp page via link which will expire after 3 days if not use?   Link is in a mail and if changes occur it will update in database
how to design a jsp page via link which will expire after 3 days if not use?
how to design a jsp page via link which will expire after 3 days if not use?   Link is in a mail and if changes occur it will update in database
Reload the page after ValueChangeListener is invoked
Reload the page after ValueChangeListener is invoked  How to reload the page after ValueChangeListener is invoked
JSP Servlet update patient data - JSP-Servlet
JSP Servlet update patient data  Hi Friend, I'm attaching my... the HTTP Get request*/ @Override public void doPost(HttpServletRequest req..._update="Data has been successfully inserted!"; String title="Update Message
update
update  how can i update multiple records in database using jsp ,servlet and jdbc based on selection of checkbox in jsp
How to change table row color when click on Hyper Link in jsp?
How to change table row color when click on Hyper Link in jsp?  I use 5 links: Link 1 Link 2 Link 3.. table: row1 row2 row3.. when click on the link1 automatically change
forwarding request to a jsp from a filter and displaying image in that jsp
forwarding request to a jsp from a filter and displaying image in that jsp ... And i am forwarding request...").forward(request, response); Above line is forwarding the request to login.jsp
methods can be invoked by the container on a stateless session bean
methods can be invoked by the container on a stateless session bean  Which of the following methods can be invoked by the container on a stateless session bean
What happens to the static fields of a class during serialization?
What happens to the static fields of a class during serialization?   What happens to the static fields of a class during serialization?   Hi, Here is the answer, There are three exceptions in which serialization
how to add a update button in the following jsp
how to add a update button in the following jsp  Once the excel from the following jsp is loaded to the broswer, how to add a button in the jsp to allow the user to update the excel? thanks, <%@page import="java.io.*"%>
Request Parameters in JSP
Request Parameters in JSP       In this section, you will study about the various request parameters. HttpServletRequest interface is responsible for providing request
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
Request Headers in JSP
Request Headers in JSP          Whenever an http client sends a request, it sends the request in the form of get or post method or any other HttpRequest 
Request Path in JSP
Request Path in JSP       This section illustrates you how to get the request path in JSP. We are providing you an example which shows the request path. The HTTPServletRequest
Advertisements
 

 

 

DMCA.com