Ragini Shukla
Please Reply
4 Answer(s)      7 years ago
Posted in : Java Beginners
Advertisement
View Answers

August 19, 2008 at 11:54 AM


Hi friend,


Code to solve your problem :

"vendmaster.jsp"


<html>
<head>

</head>
<body>

<form name="vendForm" method="post" action="vendmid.jsp">
<table>


<tr>
<td>Vend Id</td>
<td><input type="text" name="vend_id" value=""></td>
</tr>
<tr>
<td>Vend Name</td>
<td><input type="text" name="vend_name" value=""></td>
</tr>

<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>


</body>
</html>



August 19, 2008 at 11:55 AM


To insert vendmaster form "vendmid.jsp"

<%@ page language="java" import="java.sql.*;"%>
<%

// initialze the parameter form

String vend_id = "";
String vend_name = "";


// initialze the database connectivity
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";
String submit="";


if(request.getParameter("Submit")!=null)
{
vend_id = request.getParameter("vend_id");
vend_name = request.getParameter("vend_name");
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
String strQuery=null;

strQuery = "insert into vend_master set vend_id='"+vend_id+"',vend_name='"+vend_name+"'";
int rs = st.executeUpdate(strQuery);

System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}

%>


August 19, 2008 at 11:56 AM


To create a prodmaster form "prodmaster.jsp"

<%@ page language="java" import="java.sql.*;"%>
<html>
<head>

</head>
<body>

<form name="prodForm" method="post" action="prodmid.jsp">
<table>

<tr>
<td>Product Id</td>
<td><input type="text" name="prod_id" value=""></td>
</tr>
<tr>
<td>Product Name</td>
<td><input type="text" name="prod_name" value=""></td>
</tr>

<tr>
<td>Product Id</td>
<td><input type="text" name="prod_opstock" value=""></td>
</tr>
<tr>
<td>Product Name</td>
<td><input type="text" name="prod_excise" value=""></td>
</tr>

<tr>
<td>Product Id</td>
<td><input type="text" name="prod_vat" value=""></td>
</tr>
<tr>
<td>Product Name</td>
<td><input type="text" name="reorder_level" value=""></td>
</tr>
<tr>
<td>Product Id</td>
<td><input type="text" name="reorder_qty" value=""></td>
</tr>
<tr>
<td>Product Name</td>
<td><select name="vend_id">
<%
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";
String submit="";






try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
String strQuery=null;



strQuery = "select * from vend_master";
ResultSet rs = st.executeQuery(strQuery);
out.println(strQuery);
while(rs.next())
{
%>

<option value="<%=rs.getString(1)%>"><%=rs.getString(2)%></option>
<%
}



System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}


%>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>


</body>
</html>




August 19, 2008 at 11:58 AM


To save data prodmaster in database "prodmid.jsp"


<%@ page language="java" import="java.sql.*;"%>
<%

// initialze the parameter form

String prod_id = "";
String prod_name = "";
String prod_opstock = "";
String prod_excise = "";
String prod_vat = "";
String reorder_level = "";
String reorder_qty = "";
String vend_id = "";


// initialze the database connectivity
Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "test";
String driver = "com.mysql.jdbc.Driver";
String username = "root";
String userPassword = "root";
String submit="";


if(request.getParameter("Submit")!=null)
{

prod_id = request.getParameter("prod_id");
prod_name = request.getParameter("prod_name");
prod_opstock = request.getParameter("prod_opstock");
prod_excise = request.getParameter("prod_excise");
prod_vat = request.getParameter("prod_vat");
reorder_level = request.getParameter("reorder_level");
reorder_qty = request.getParameter("reorder_qty");
vend_id = request.getParameter("vend_id");

out.println(vend_id);
try {
Class.forName(driver).newInstance();
conn = DriverManager.getConnection(url+dbName,username,userPassword);
Statement st = conn.createStatement();
String strQuery=null;

strQuery = "insert into prod_master set prod_id='"+prod_id+"',prod_name='"+prod_name+"',prod_opstock='"+prod_opstock+"',prod_excise='"+prod_excise+"',prod_vat='"+prod_vat+"',reorder_level='"+reorder_level+"',reorder_qty='"+reorder_qty+"',vend_id='"+vend_id+"'";

int rs = st.executeUpdate(strQuery);

System.out.println("Connected to the database");
conn.close();
System.out.println("Disconnected from database");
} catch (Exception e) {
e.printStackTrace();
}
}

%>

For read more information

http://www.roseindia.net/

Thanks

vineet









Related Tutorials/Questions & Answers:
PLease reply its urgent
PLease reply its urgent   Write a java function that has the signature ΓΆβ?¬Ε?Public static int clock Inter sections(int hours, int minutes)ΓΆβ?¬Β? That takes a number of hours and minutes (up to several days), and returns
Please Reply - Java Beginners
Please Reply  Hi, I have a form these fields r prod_id,prod_name,prod_opstock,prod_excise,prod_vat,reorder_level,reorder_qty,vend_name... should be stored vand_id in the place of vend_name Please write a code
Advertisements
Java Program(Please reply asap)
Java Program(Please reply asap)  Find out the ways in which numbers can be added to get the same result Example:- 10 1+9=10 1+2+3+4=10 1+9=10
please reply the code to store dynamic fields in database?
please reply the code to store dynamic fields in database?  <%@ page import ="java.sql.*" %> <%@ page import ="javax.sql.*" %> <%@page contentType="text/html" pageEncoding="UTF-8"%> <title>Login User<
Would you know answer means please send reply urgent
Would you know answer means please send reply urgent  HTTP Status 404 - /struts/HelloWorld.jsp type Status report message /struts/HelloWorld.jsp description The requested resource (/struts/HelloWorld.jsp) is not available
struts problem ... need help urgently.. please reply ASAP
struts problem ... need help urgently.. please reply ASAP  Hi Every1, I want to make an application using struts 1.2. I am a beginner on struts... depends on server or IDE. Please reply ASAP. Thanx , am2085
please reply fast if anyone knows that how to install mysql on windows using msi package
please reply fast if anyone knows that how to install mysql on windows using msi package  please reply fast if anyone knows that how to install mysql on windows using msi package   Hello Friend, visit here Thanks
reply must
reply must  is it critical to do a software job based on games(java) i know core java & advanced java basics only please give me answer
reply to the mail
reply to the mail  Hi! which jar file needed to be added? Thanks   Question not clear
Reply Me - Java Beginners
Reply Me  Hi, This is not correct url please send me again coorect url
Reply - Struts
Reply   Thanks For Nice responce Technologies::--JSP please write the code and send me....when click "add new button" then get the null value...its urgent...  Hi can u explain in details about your project
Reply - Struts
Reply  Hello Friends, please write the code in struts and send me I want to display "Welcome to Struts" please send me code its very urgent... and which file need to be run and compile struts without using database
Reply - Struts
Reply  I am sending some coding please chk and let me know if(act==3) { W=0; while(W< (txtcnt4-1)) { out.println("1st Details==::" + request.getParameter("txtICNAMEOFOCCP" + W
Reply me - Java Beginners
Reply me  Hi,   Hi Ragini please specify main problem. where are problem in your code. Thanks
reply - Java Beginners
reply  Hi friends I have a 255 fields i want to insert data in the table please let me know how to insert data in the database please reply me its very urgent
Reply me - Java Beginners
Reply me  Hi Friends, Quest:- Tell em what is the difference between java and php, dotnet Quest:- what is the similar point of php and java... Please tell me its very urgent
Reply Me - Java Beginners
=13c222b87273340cf002bfba4ab9d045. please reply me fast its urgent...Reply Me  Hi All, I want to using query string in my page please write the query string in java script and send me and I have a some link
Reply Me - Struts
Reply Me  Hi Friends, Please write the code using form element...because i got error in textbox null value  Hi Soniya Would you please explain, in which technology are you creating page? I promise
Reply me - Java Beginners
Reply me  If u r not understood my just posted question plz let me know  Hi Ragini, Please specify your requirements in detail. It would be good for me to provide you the solution if problem is clear. And also
Reply Me - Struts
Reply Me  Hi Friends, I am new in struts please help me... file,connection file....etc please let me know its very urgent   Hi Soniya, I am sending you a link. This link will help you. Please
Reply me - Java Beginners
Reply me  Hi, There are one form product_master these fields are prod_id,prod_name,prod_opstock,prod_excise,prod_vat,reorder_level,reorder_qty... in the place of vend_name Please write this code and send me its very urgent
reply me - Java Beginners
reply me  Hi, user enter vend_id in text box ten open the addform.jsp In the addform.jsp have two button Update and delete... is incorrect user click delete button then file is not called please send
Reply me - Java Beginners
Reply me   Hi, I am using this code for session but i am... then adll data would be displaying. so please tell me what is incorrect my code and i want to use session in each page then please tell me that how can i
Reply Me - Java Beginners
Reply Me  Hi Amardeep I am sending database table name,code and db file please insert this data in this table its very urgent.... My... "code too large for try statement" please help me its very urgent
Reply - JSP-Servlet
numberformat exception to display "Please enter Valid ID" in the form of an alert box... Thanks for your fast reply.. Thanks/Regards, R.Ragavendran..  
Reply Me - Java Beginners
Reply Me  Hi, Please Help Me using jsp technologies I have a form click the link and open the popup window main page have already a html... understood my problem then please send me.....  Hi friend, Please
Reply Me - Java Beginners
Reply Me  Hi deepak, your sending web application is good (alphabetical searching dropdown menu) Steps:- 1:-searching is good... will be not displayed. please help me how it is open selection of the user its very urgent
Reply me soon.........
Reply me soon.........  Any body plzz help.....how to get d checked details from previous page to current page and den insert into table
Reply Me - Java Beginners
Reply Me  Hi, I m working in jsp please any information provide... based onsearching Search with name alphabetical order please understood,if u not understood then please tell me Thanks   
Reply Me - Java Beginners
Reply Me  Hi,.. I have a some fields in one form like security and some more fields this fields maintain the table if user click security... question then reply me