Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
update using parameters in jsp page
12-14-2011, 04:04 PM (This post was last modified: 12-14-2011 04:15 PM by rajasri.)
Post: #1
Shocked update using parameters in jsp page
Today you are going to learn how t update using parameters in jsp page.This simple example uses mysql you can use your own database..

First create a form named form.html

Quote:<form name="simple" action="updb.jsp" method="get" >
<input type="text" name="paramone"/>
<input type="text" name="paramtwo"/>
<input type="submit" />
<form/>

Next create updb.jsp
<%@ page import="java.sql.*"%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/way2start","root","root");
Statement st=con.createStatement();
Statement st1=con.createStatement();
String two=request.getParameter("paramone");
String twomodify=request.getParameter("paramtwo");
st.executeUpdate("update one set name='"+two+"' where (name='"+twomodify+"')");
ResultSet rs=st1.executeQuery("select * from one");
while(rs.next())
{
out.println("<html>");
out.println("<body>");
out.println("<table bgcolor='green'>");
out.println("<tr>");
out.println("<td>");
out.println(rs.getString(1));
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</body>");
out.println("</html>");
}
%>
The url pass like this
//http://localhost:8084/ImporterandExporter/update.jsp?name=safiq&name1=safiq1
Tutorial Provided by In order to view links, you must have to reply to this thread. Visit for More Tutorials


Any doubt ask us.

Happy coding
Find all posts by this user
Add Thank You Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies Views: Last Post
Big Grin In Tomcat jsp page is not refreshing rajasri 0 62 12-19-2011 10:41 PM
Last Post: rajasri
Thumbs Up Display combo box value/Database value on same JSP page rajasri 0 73 12-19-2011 09:27 PM
Last Post: rajasri
Its My Birthday! Display database value in jsp page rajasri 0 240 12-14-2011 04:13 PM
Last Post: rajasri
Video simple update query in jsp page rajasri 0 357 12-14-2011 04:06 PM
Last Post: rajasri
Big Grin using session to protect a page in jsp rajasri 0 216 12-13-2011 04:47 AM
Last Post: rajasri
Its My Birthday! How to pass and get values in href as parameters in Jsp rajasri 0 490 12-13-2011 04:34 AM
Last Post: rajasri
Video Display current time and date in your Jsp page rajasri 0 383 12-13-2011 04:26 AM
Last Post: rajasri
Star Getting number of rows in jsp page rajasri 0 233 12-13-2011 04:23 AM
Last Post: rajasri
Video How to use batch update in java and jsp rajasri 0 202 12-13-2011 04:08 AM
Last Post: rajasri
Star Read data from xml and show in jsp page project download rajasri 0 325 12-13-2011 04:00 AM
Last Post: rajasri

Forum Jump:


User(s) browsing this thread: 1 Guest(s)


WE will share important jobs and updates on facebook so like us to get updates