Online Hibernate Training just in Rs. 1000

One week online training in Hibernate ORM framework. Learn Hibernate Framework and enhance your skills. Best Online Hibernate training at 90% discount. Join Now!! Offer is valid Only for limited Period!!! Online Training Big Data and Hadoop Training Java Training  
 

jsp update request happens to be invoked by a link

Ads

 
 

Share on Google+Share on Google+

akshatha
jsp update request happens to be invoked by a link
2 Answer(s)      6 years and 5 months 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

Ads
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:

<[email protected] language="java"%>
<[email protected] 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:

<[email protected] 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);
}
%>

Ads









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
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
Advertisements
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"/>
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
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
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 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
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
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
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
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
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
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
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
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
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
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
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
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.
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
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
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
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
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
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 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
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