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



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

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


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


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
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"/>
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
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
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
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
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
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 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 retrieve link - JSP-Servlet
how to retrieve link  how to retrieve link of a web page and use it as input in the program
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
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 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
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
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
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
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
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
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
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
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  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
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
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
Advertisements
 

 

 

DMCA.com