Failed to insert data in database with PreparedStatement with jsp - java

I'm trying to insert data into database using PreparedStatement based on form input. The program follows normal flow when user clicks "submit" on the checkout page (checkout.jsp) the form redirect him to the confirmation.jsp as wanted but no data gets inserted. When user submit forms, the program seems to ignore the PreparedStatement and only notices the userPath. I wonder what could be the cause of this behavior? No error gets printed.
Servlet.java
} else if (userPath.equals("/purchase")) {
String OD = request.getParameter("OD");
String FN = request.getParameter("FN");
String LN = request.getParameter("LN");
String PN = request.getParameter("PN");
String EM = request.getParameter("EM");
String A1 = request.getParameter("A1");
String A2 = request.getParameter("A2");
String CT = request.getParameter("CT");
String SPR = request.getParameter("SPR");
String PZC = request.getParameter("PZC");
String CTRY = request.getParameter("CTRY");
String referenceNumber = request.getParameter("referenceNumber");
String status = request.getParameter("status");
String queue = request.getParameter("queue");
String cart_total = request.getParameter("cart_total");
String order_details = request.getParameter("order_details");
try{
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/application?user=root&password=12345");
PreparedStatement pst;
pst = connection.prepareStatement("insert into customer_order(date_created, first_name,last_name,phone,email,address_1,address_2,city,State_Province_Region,Postal_Zip_Code,country,referenceNumber,status,queue,cart_total,order_details) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
//When concating strings you should do something like st = connection.prepareStatement("Insert into student values ('" + userid + "','"+pw+"')"); but the right way is
//st = connection.prepareStatement("Insert into student values (1,2)");
pst.setString(1,OD);
pst.setString(2,FN);
pst.setString(3,LN);
pst.setString(4,PN);
pst.setString(5,EM);
pst.setString(6,A1);
pst.setString(7,A2);
pst.setString(8,CT);
pst.setString(9,SPR);
pst.setString(10,PZC);
pst.setString(11,CTRY);
pst.setString(12,referenceNumber);
pst.setString(13,status);
pst.setString(14,queue);
pst.setString(15,cart_total);
pst.setString(16,order_details);
pst.executeUpdate();
}catch(ClassNotFoundException | SQLException ex){
//print a message or something
}finally{
Connection connection = null;
if (connection!=null){
try {
connection.close();
} catch (SQLException ex) {
Logger.getLogger(ControllerServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
userPath = "/confirmation";
}
Checkout.jsp
<form id="shipping_form" method="post" action="purchase" name="checkout">
<label for="date" class="shp_label">Order Date </label>
<input id="date" name="OD" type="text" class="shp_ipt" value="<%= new java.util.Date()%>" readonly>
<label for="fname" class="shp_label">First Name </label>
<input id="fname" name="FN" type="text" class="shp_ipt" required>
<label for="lname" class="shp_label">Last Name </label>
<input id="lname" name="LN" type="text" class="shp_ipt" required>
<label for="phone" class="shp_label"> Phone </label>
<input id="phone" name="PN" type="text" class="shp_ipt" required>
<label for="email" class="shp_label"> Email </label>
<input id="email" name="EM" type="email" class="shp_ipt" required>
<label for="add1" class="shp_label"> Address 1 </label>
<input id="add1" name="A1" type="text" class="shp_ipt" required>
<label for="add2" class="shp_label"> Address 2 </label>
<input id="add2" name="A2" type="text" class="shp_ipt">
<label for="city" class="shp_label"> City </label>
<input id="city" name="CT" type="text" class="shp_ipt" required>
<label for="spr" class="shp_label"> Region </label>
<input id="spr" name="SPR" type="text" class="shp_ipt" required>
<label for="pzc" class="shp_label"> Zip / Code </label>
<input id="pzc" name="PZC" type="text" class="shp_ipt" required>
<label for="country" class="shp_label"> Country </label>
<input id="country"name="CTRY" type="text" class="shp_ipt" required>
<input type="hidden" name="referenceNumber" value="<%=System.currentTimeMillis()%>" />
<input type="hidden" name="staus" value="Pending" />
<input type="hidden" name="queue" value="This information will be updated soon." />
<input type="hidden" class="cartTotal" style="border:none; background:transparent;" name="cart_total" readonly type="text" value="${cart.total}"/>
<input type="hidden" name="order_details" value="Your order is being processed." />
<input class="submit_button button" name="submit" value="Ship Me!" type="submit">
</form>

If you have no error found then you can change some code in preparedStatement . Like this -
pst = connection.prepareStatement("insert into customer_order values('"+FN+"', '"+LN+"',.........) ");
And one think remember that after PreparedStatement it is must be perform execute() method , by PreparedStatement's object . Like this -
pst.execute();

Related

get id of nested object from form on thymeleaf

i have 2 entity class, parkingUser and parkingDetails, user can have many parking details(one to many).
parkingUserobject contain: [id, firstName, lastName,parkingDetails[id, entryDate,...,user_id(FK)]]
in parkingUser i had List of parkingDetails(its my FK)
#OneToMany(mappedBy = "parkingUsers", cascade = CascadeType.ALL, orphanRemoval = true)
private List<parkingDetails> parkingDetails = new ArrayList<parkingDetails>();
so now i have a thymeleaf page that recive from controller model of user and model of parking, its showing exist data on form input fields, and adding more data of exit date and exit time on the object in the c'tor on the controller that recive the form.
after that what i want to achive is to get the id of parking.id,
but its send me from a form the id of user.id
my controller with prints to understood what i get from the form:
(lets say i enter to form on user id =1, its create on the controoler new object of parkingDetails, and save it on db,
after that i want to delete the new object that created with id 35, and the object that pass from the form of parking.id, but i cant access this data.
#PostMapping("/saveDateAndTimeOfExitParking")
public String saveNewUserFromFormAction(
#ModelAttribute("user") parkingUsers parkingUsers,
#ModelAttribute("details") parkingDetails parkingDetails) {
//need to store to details table date and time
String str = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"));
System.out.println(parkingUsers);
//parkingUsers [id=1, firstName=David, lastName=Adams, license=2356584, parkingDetails=[]]
System.out.println(parkingDetails);
//parkingDetails [id=1, entryDate=2022-05-18, entryTime=08:35:20, exitDate=null, exitTime=null, parkingUsers=null]
System.out.println(parkingUsers.getParkingDetails());
//[]
parkingDetails d = new parkingDetails(
parkingDetails.getEntryDate(),
parkingDetails.getEntryTime(),
LocalDate.now(),
str);
d.setParkingUsers(parkingUsers);
parkingDetailsService.saveParkingUser(d);
//store the object of parking details on new db of history
//and then remove it from main schema
System.out.println(d.getId());
//35
System.out.println(parkingDetails.getId());
//1
parkingDetailsService.deleteParkingEntrySession(d.getId());
//i want to delete also the parkingDetails object from the form, but its gave me the id of parkingUser
//parkingDetailsService.deleteParkingEntrySession(parkingDetails.getId());
return "redirect:/exit";
}
my form:
<div class="formCenterAndWidth">
<form action="#" th:action="#{/saveDateAndTimeOfExitParking}" method="POST">
<input type="hidden" th:field="*{user.id}"/>
<div class="form-group row">
<label class="col-sm-2 col-form-label">User Id:</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{user.id}">
</div>
<label class="col-sm-2 col-form-label">Parking Id:</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{parking.id}">
</div>
<label class="col-sm-2 col-form-label">First Name:</label>
<div class="col-sm-10">
<input class="form-control" type="text" th:field="*{user.firstName}">
</div>
<label class="col-sm-2 col-form-label">Last Name:</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{user.lastName}">
</div>
<label class="col-sm-2 col-form-label" style="white-space: nowrap;">License Number</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{user.license}">
</div>
<label class="col-sm-2 col-form-label">Entry Date</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{parking.entryDate}">
</div>
<label class="col-sm-2 col-form-label">Entry Time</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:field="*{parking.entryTime}">
</div>
<label class="col-sm-2 col-form-label">Exit Date</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:value="${#dates.format(exitDateAndTime, 'dd-MM-yyyy')}">
</div>
<label class="col-sm-2 col-form-label">Exit Time</label>
<div class="col-sm-10">
<input readonly class="form-control" type="text" th:value="${#dates.format(exitDateAndTime, 'HH:mm:ss')}">
</div>
<br><br>
<button type="submit" class="btn btn-info col-7 center">Exit Car</button>
</div>
</form>

getting Null value from on Servlet from request.getParameter() from JSP

I am sending text values from jsp to servlet but in servlet request.getParameter() gives me null values. Below I am mentioning my JSP, Servlet and web.xml
REGISTER.JSP
<form id="contactform" action="servlet/SaveInfo" method="post">
<p class="contact"><label for="email">Email</label></p>
<input id="email" name="email" placeholder="example#domain.com" required="" tabindex="1" type="email">
<p class="contact"><label for="username">User Name</label></p>
<input id="username" name="username" placeholder="username" required="" tabindex="2" type="text">
<p class="contact"><label for="password">Password</label></p>
<input type="password" id="password" name="password" required="" tabindex="3">
<p class="contact"><label for="repassword">Confirm Password</label></p>
<input type="password" id="repassword" name="repassword" required="">
<p class="contact"><label for="phone">Mobile Phone</label></p>
<input id="phone" name="phone" placeholder="phone number" required="" tabindex="4" type="text"> <br>
<p class="contact"><label for="name">Organization Name</label></p>
<input id="Orgname" name="name" placeholder="Organization name" required="" tabindex="5" type="text">
<p class="contact"><label for="Address">Address</label></p>
<input id="address" name="name" placeholder="Street,Area,city" required="" tabindex="6" type="text"> <br>
<!-- <select class="select-style" name="BirthMonth"> -->
<label>State</label><br>
<select class="select-style" name="BirthMonth">
<%
ResultSet rs = null;
Connection con = null;
PreparedStatement pmst1= null;
int countryid = 208;
try{
con = DBConnectivity.getOracleDBConnection();
pmst1 = con.prepareStatement(Sqlquery.getRegion());
pmst1.setInt(1, countryid);
rs=pmst1.executeQuery();
while(rs.next()){
String name = rs.getString("name");
%>
<option value="<%=name %>"><%=name %></option>
<% } %>
<%
}catch(Exception e){
}
%>
</select><br><br>
<p class="contact"> <input id="check" name="name" style="margin-right: 10px" type="checkbox">
<label for="name"> Not Yet Registered GSTIN</label> </p>
<p class= "GSTIN"><label for="GSTIN">GSTIN No.</label></p><br>
<input id = "GSTINNO" maxlength="15" name= "GSTIN" placeholder="GSTIN No." type ="text"><br><br>
<input class="buttom" name="submit" id="submit" tabindex="5" value="Sign me up!" type="submit">
SaveInfo.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try{
ResultSet rs = null;
Connection con = null;
PreparedStatement pmst1= null;
String Orgname = request.getParameter("Orgname");
String check =request.getParameter("check");
String GSTINNO = request.getParameter("GSTINNO");
con = DBConnectivity.getOracleDBConnection();
int clientid = 1000014;
MClient Client = new MClient (Env.getCtx(), clientid, null);
I want all the values in my servlet class and save that values in database below I am mentioning my web.xml file
Kindly help me out
<servlet>
<description></description>
<display-name>SaveInfo</display-name>
<servlet-name>SaveInfo</servlet-name>
<servlet-class>com.org.register.SaveInfo</servlet-class>
<servlet-mapping>
<servlet-name>SaveInfo</servlet-name>
<url-pattern>/servlet/SaveInfo</url-pattern>
</servlet-mapping>
In Servlet you need to get parameters by name attribute, not id.
For example, You have the following,
<input id="Orgname" name="name" placeholder="Organization name" required="" tabindex="5" type="text">
Here you have given id to be Orgname and name parameter is name. So in Servlet you will do,
request.getParameter("name");
But you are doing,
String Orgname = request.getParameter("Orgname");
Secondly, you cannot have same name for two parameters. For both the following you have given name to be name
<input id="Orgname" name="name" placeholder="Organization name" required="" tabindex="5" type="text">
<input id="address" name="name" placeholder="Street,Area,city" required="" tabindex="6" type="text"> <br>
Give some different name to the parameters.
The getParameter function of request object works with name attribute. So please replace your jsp with following.
<form id="contactform" action="servlet/SaveInfo" method="post">
<p class="contact"><label for="email">Email</label></p>
<input id="email" name="email" placeholder="example#domain.com" required="" tabindex="1" type="email">
<p class="contact"><label for="username">User Name</label></p>
<input id="username" name="username" placeholder="username" required="" tabindex="2" type="text">
<p class="contact"><label for="password">Password</label></p>
<input type="password" id="password" name="password" required="" tabindex="3">
<p class="contact"><label for="repassword">Confirm Password</label></p>
<input type="password" id="repassword" name="repassword" required="">
<p class="contact"><label for="phone">Mobile Phone</label></p>
<input id="phone" name="phone" placeholder="phone number" required="" tabindex="4" type="text"> <br>
<p class="contact"><label for="name">Organization Name</label></p>
<input id="Orgname" name="Orgname" placeholder="Organization name" required="" tabindex="5" type="text">
<p class="contact"><label for="Address">Address</label></p>
<input id="address" name="address" placeholder="Street,Area,city" required="" tabindex="6" type="text"> <br>
<!-- <select class="select-style" name="BirthMonth"> -->
<label>State</label><br>
<select class="select-style" name="BirthMonth">
<%
ResultSet rs = null;
Connection con = null;
PreparedStatement pmst1= null;
int countryid = 208;
try{
con = DBConnectivity.getOracleDBConnection();
pmst1 = con.prepareStatement(Sqlquery.getRegion());
pmst1.setInt(1, countryid);
rs=pmst1.executeQuery();
while(rs.next()){
String name = rs.getString("name");
%>
<option value="<%=name %>"><%=name %></option>
<% } %>
<%
}catch(Exception e){
}
%>
</select><br><br>
<p class="contact"> <input id="check" name="name" style="margin-right: 10px" type="checkbox">
<label for="name"> Not Yet Registered GSTIN</label> </p>
<p class= "GSTIN"><label for="GSTIN">GSTIN No.</label></p><br>
<input id = "GSTINNO" maxlength="15" name= "GSTIN" placeholder="GSTIN No." type ="text"><br><br>
<input class="buttom" name="submit" id="submit" tabindex="5" value="Sign me up!" type="submit">
JSP post parameters using their attribute name. you wrote the wrong attribute name in 3 parameters.
Change:
<input id="check" name="name"
<input id="Orgname" name="name"
<input id="address" name="name"
To:
<input id="check" name="check"
<input id="Orgname" name="Orgname"
<input id="address" name="address"

Validation in jsp page

I am using a form where i am adding an state into the database but now i want to use a server side validation for this form (like checking whether it is empty or not.) So please help me in this.
By the way i am new in jsp and want to learn server side validation in jsp page so plese let me know how to go about it.
String sql="insert into tblstate(fkCountry_Id,fldstate) "
+ "values('"+cou+"','"+sta+"')";
try{
conn.createStatement().executeUpdate(sql);
conn.setAutoCommit(true);
// New location to be redirected
String site = new String("add_state.htm");
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location", site);
}catch(Exception e){
e.printStackTrace();
}
%>
" method="POST">
<div class="control-group">
<label class="control-label" for="selectError">Country</label>
<select class="form-control" name="cou">
<option value="none">Select</option>
<%
String sql_cou = "select * from tblcountry";
PreparedStatement coun=conn.prepareStatement(sql_cou);
ResultSet rs_cou = coun.executeQuery(sql_cou);
while(rs_cou.next()){
out.println("<option value=" + rs_cou.getString("pkCountry_Id")+ "> " + rs_cou.getString("fldCountry")+"</option>");
}
%>
</select>
</div>
<div class="form-group">
<label for="exampleInputEmail1">State</label>
<input name="sta" type="text" class="form-control" id="exampleInputEmail1" placeholder="Enter Dzongkhag">
</div>
<button type="submit" class="btn btn-default">Submit</button>
<button type="reset" class="btn btn-default">Cancel</button>
</form>
</div>

How to pass the radio button value which is clicked to controller?

I am using Spring MVC controller.
Below is my JSP code in which it will show three radio button. One is Insert, second radio button is Update and third radio button is Delete.
Once I click Insert radio button, it show two text box next to Insert radio button, and same thing with other two radio button.
<script type="text/javascript">
function doDisplay(radio) {
switch (radio.value) {
case "Insert":
document.getElementById("inserts").style.display = "inline";
document.getElementById("updates").style.display = "none";
document.getElementById("delete").style.display = "none";
break;
case "Update":
document.getElementById("inserts").style.display = "none";
document.getElementById("updates").style.display = "inline";
document.getElementById("delete").style.display = "none";
break;
case "Delete":
document.getElementById("inserts").style.display = "none";
document.getElementById("updates").style.display = "none";
document.getElementById("delete").style.display = "inline";
break;
}
}
</script>
<body>
<form method="post" action="testOperation">
<input type="radio" name="tt" value="Insert"
onclick="doDisplay(this);" /> Insert <input type="hidden" name="name" value="insert"><span id="inserts"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100" />
</span> <br /> <input type="radio" name="tt" value="Update"
onclick="doDisplay(this);" /> Update <input type="hidden" name="name" value="update"> <span id="updates"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100"/>
</span> <br /> <input type="radio" name="tt" value="Delete"
onclick="doDisplay(this);" /> Delete <input type="hidden" name="name" value="delete"><span id="delete"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100"/>
</span> <br />
<input type="submit">
</form>
Now what I am trying to do is as soon as I click on Insert radio button, it will show me two textbox next to Insert radio button. And after putting some values inside those two text box, I press submit button on the form. And then it goes to testOperations method in which name field has these many things -
insert,update,delete
How can I force it to have only one field which I am clicking only? Meaing if I am clickign insert radio button, then name variable should have insert value? Below is my method -
#RequestMapping(value = "testOperation", method = RequestMethod.GET)
public Map<String, String> testOperation() {
final Map<String, String> model = new LinkedHashMap<String, String>();
return model;
}
#RequestMapping(value = "testOperation", method = RequestMethod.POST)
public Map<String, String> testOperations(#RequestParam String name,
#RequestParam String node,
#RequestParam String data) {
final Map<String, String> model = new LinkedHashMap<String, String>();
System.out.println(name);
System.out.println(node);
System.out.println(data);
return model;
}
Meaning, Suppose I click Insert radio button and type Hello in the first text and World in the second text box, then I will hit the submit button, and after that I should see insert value in the name variable and hello value in the node variable and world value in the data variable.
And same thing with update and delete.
Is this possible to do?
You have done correct. All you need to do is while click the radio button set the value on name. One hidden variable is enough. Your html part look like this,
<form method="post" action="testOperation">
<!-- I used only one hidden box to store value -->
<input type="hidden" name="name" id="dynamicName">
<input type="radio" name="tt" value="Insert"
onclick="doDisplay(this);" /> Insert <span id="inserts"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100" />
</span> <br /> <input type="radio" name="tt" value="Update"
onclick="doDisplay(this);" /> Update <span id="updates"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100"/>
</span> <br /> <input type="radio" name="tt" value="Delete"
onclick="doDisplay(this);" /> Delete <span id="delete"
style="display: none"> <label for="Node"> Node </label> <input
type="text" name="node" size="20" /> <label for="Data"> Data </label>
<input type="text" name="data" size="100"/>
</span> <br />
<input type="submit">
</form>
And in script,
<script type="text/javascript">
function doDisplay(radio) {
switch (radio.value) {
case "Insert":
document.getElementById("inserts").style.display = "inline";
document.getElementById("updates").style.display = "none";
document.getElementById("delete").style.display = "none";
document.getElementById("dynamicName").value = "insert";
break;
case "Update":
document.getElementById("inserts").style.display = "none";
document.getElementById("updates").style.display = "inline";
document.getElementById("delete").style.display = "none";
document.getElementById("dynamicName").value = "update";
break;
case "Delete":
document.getElementById("inserts").style.display = "none";
document.getElementById("updates").style.display = "none";
document.getElementById("delete").style.display = "inline";
document.getElementById("dynamicName").value = "delete";
break;
}
}
</script>
Hope this helps.
You have inputs with same names, you don't need other hidden. A single node and data inputs are enough
This HTML is enough:
<input type="radio" name="tt" value="Insert" onclick="doDisplay(this);" /> Insert<br/>
<input type="radio" name="tt" value="Update" onclick="doDisplay(this);" /> Update<br/>
<input type="radio" name="tt" value="Delete" onclick="doDisplay(this);" /> Delete<br/>
<label for="Node"> Node </label> <input type="text" name="node" size="20" /><br/>
<label for="Data"> Data </label> <input type="text" name="data" size="100"/><br/>
<input type="submit">
Here is the controller function:
public Map<String, String> testOperations(
#RequestParam(value="tt", required=false) String name,
#RequestParam(value="node", required=false) String node,
#RequestParam(value="data", required=false) String data) {
//...
}

how to give HTML5 validations into hidden label when the submit button is clicked in JSP?

I am using html5 validation for my form in jsp page. I have given novalidate in form. When i click on submit button of that form it should validate the form now and display all validation in one label which was hidden before.How can i get these in jsp?
This is my form code.
<form action="#join1_form" method="POST">
<div>
<input type="text" name="firstname" id="firstname" value="" required placeholder="First Name" pattern="\w+" />
<input type="text" name="lastname" id="lastname" value="" required placeholder="Last Name" pattern="\w+" />
</div>
<div>
<input type="email" name="email" placeholder="Your Email" id="email" value="" required />
</div>
<div>
<input name="password" id="password" type="password" required placeholder="New Password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="password" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Password must contain at least 6 characters, including UPPER/lowercase and numbers' : '');
if(this.checkValidity()) form.cpassword.pattern = this.value;">
</div>
<div>
<input name="cpassword" id="cpassword" type="password" placeholder="Re-enter Password" required pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])\w{6,}" name="cpassword" onchange="this.setCustomValidity(this.validity.patternMismatch ? 'Please enter the same Password as above' : '');">
</div>
<div>
<input type="label" hidden value="">
</div>
<input type="submit" value="Next">
</form>
I want to display all the validation notes after submitting the submit button.These validations should displaye in textfield which is given hidden here.how can i do that?
this is my code for not repeating the emailID. where should i put this in above form?How to display its validation in the textfield which is given hidden above?
<%
Connection conn = null;
PreparedStatement ps=null;
ResultSet rs = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "");
String email1=request.getParameter("lemail");
try{
String q="SELECT * FROM userdetails where email=?";
ps=conn.prepareStatement(q);
ps.setString(1,email1);
rs=ps.executeQuery();
if(rs.next())
{
//what to do here?
}
else
{
//what to do here?
}
}
catch(Exception e)
{
e.printStackTrace();
}
try{
if(ps!=null){
ps.close();
}
if(rs!=null){
rs.close();
}
if(conn!=null){
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
<html:form action="storenotes" onsubmit="return demo()">
call demo() function in your JavaScript
and submit form by
return true
or
return false

Categories

Resources