Hi. I am getting error in the following code after the line I have commented as ERROR. How to solve this. Thanks in advance.
package com.dept.iso;
import java.io.IOException; import java.io.PrintWriter; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet;
import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
import com.mysql.jdbc.Connection;
/** * Servlet implementation class Modifystdfamily */ @WebServlet("/Modifystdfamily") public class Modifystdfamily extends HttpServlet { private static final long serialVersionUID = 1L;
/** * @see HttpServlet#HttpServlet() */ public Modify_std_family() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub PrintWriter out=response.getWriter(); String rollno=null; try { rollno=(String)request.getAttribute("rollno"); double rno; rno=Double.parseDouble(rollno); String ryr=rollno.substring(0,4); String driverName = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://localhost:3306/"; String dbName = "dept"; String userName = "root"; String password = "root"; Connection con = null; Class.forName(driverName); con = (Connection) DriverManager.getConnection(url+dbName,userName,password); PreparedStatement pre; ResultSet rs; out.println("<html>"); out.println("<head>"); out.println("<title></title>"); out.println("<script language='javascript'>"); out.println("function valid(form1)"); out.println("{"); out.println("if(document.form1.fname.value=='')"); out.println(" {"); out.println(" alert('Please enter the Father Name !');"); out.println(" document.form1.fname.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" if(document.form1.foccupation.value=='')"); out.println(" {"); out.println(" alert('Please enter the Father Occupation !');"); out.println(" document.form1.foccupation.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var salary=document.form1.fsalary.value;"); out.println(" if(salary=='')"); out.println(" {"); out.println(" alert('Please enter the father salary !');"); out.println(" document.form1.fsalary.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" else if(isDigits(salary)==false)"); out.println(" {"); out.println(" alert('Please enter the Father salary as numeric !');"); out.println(" document.form1.fsalary.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" if(document.form1.faddress.value=='')"); out.println(" {"); out.println(" alert('Please enter the Father Addess !');"); out.println(" document.form1.faddress.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var phone = document.getElementById('ftno').value;"); // ERROR out.println(" var pattern = /^\d{3,5}([\-]\d{6,8})?$/; "); out.println(" if(phone=='')"); out.println(" {"); out.println(" alert('Please enter the Father Telephone number!');"); out.println(" document.form1.ftno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" else if (!pattern.test(phone))"); out.println(" {"); out.println(" alert('Please enter the correct Father Telephone number!');"); out.println(" document.form1.ftno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var mno=document.getElementById('fmno').value;"); out.println(" var pattern= /^\d{10}$/;"); out.println(" if(mno=='')"); out.println(" {"): out.println(" alert('Please enter the Father Mobile number!');"); out.println(" document.form1.fmno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" else if(!pattern.test(mno))"); out.println(" {"); out.println(" alert('Please enter the correct Father mobile number !');"); out.println(" document.form1.fmno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" if(document.form1.mname.value=='')"); out.println(" {"); out.println(" alert('Please enter the Mother Name !');"); out.println(" document.form1.mname.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" if(document.form1.moccupation.value=='')"); out.println(" {"); out.println(" alert('Please enter the Mother Occupation !');"); out.println(" document.form1.moccupation.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var sal=document.form1.msalary.value;"); out.println(" if(isDigits(sal)==false)"); out.println(" {"); out.println(" alert('Please enter the Mother salary as numeric !');"); out.println(" document.form1.msalary.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" if(document.form1.maddress.value=='')"); out.println(" {"); out.println(" alert('Please enter the Mother Addess !');"); out.println(" document.form1.maddress.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var phone = document.getElementById('mtno').value;"); out.println(" var pattern = /^\d{3,5}([\-]\d{6,8})?$/; "); out.println(" if(phone=='')"); out.println(" {"); out.println(" alert('Please enter the Mother Telephone number!');"); out.println(" document.form1.mtno.focus()"); out.println(" return(false);"); out.println(" }"); out.println(" else if (!pattern.test(phone))"); out.println(" {"); out.println(" alert('Please enter the correct Mother Telephone number!');"); out.println(" document.form1.mtno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" var mno=document.getElementById('mmno').value; "); out.println(" var pattern = /^\d{3,5}([\-]\d{6,8})?$/; "); out.println(" var pattern= /^\d{10}$/; "); out.println(" if(mno=='')"); out.println(" {"); out.println(" alert('Please enter the Mother Telephone number!');"); out.println(" document.form1.mmno.focus();"); out.println(" return(false);"); out.println(" }"); out.println(" else if(!pattern.test(mno))"); out.println(" {"); out.println(" alert('Please enter the correct Mother mobile number !');"); out.println(" document.form1.mmno.focus();"); out.println(" return(false);"); out.println(" }"); out.println("}"); out.println("function isDigits(check)"); out.println("{"); out.println(" var digits='1234567890'; "); out.println(" var temp;"); out.println(" for (var i=0;i<check.length;i++)"); out.println(" { temp=check.substring(i,i+1);"); out.println(" if (digits.indexOf(temp)== -1)"); out.println(" {"); out.println(" return(false);"); out.println(" }"); out.println(" }"); out.println(" return(true);"); out.println("}"); out.println("</script>"): out.println("</head>"); out.println("<body>"); out.println("<div align='center'>"); out.println("<form name='form1' method='post' action='Modify_std_family_add' onSubmit='return valid(this)'>"); pre=con.prepareStatement("select * from t"+yr+"_student_family where rollno="+rno); rs=pre.executeQuery(); if(rs.next()) { request.setAttribute("rollno",rollno); out.println("<table width='267' border='0'>"); out.println("<tr> <th height='38' colspan='3' scope='col'>STUDENT FAMILY DETAILS </th> </tr>"); out.println("<tr> <td colspan='3'><strong>Father details: </strong></td> </tr>"); out.println("<tr> <td>Name</td> <td>:</td> <td><input type=text name='fname' value="+rs.getString("fname")+"></td> </tr>"); out.println("<tr> <td>Occupation</td> <td>:</td> <td><input type=text name='foccupation' value="+rs.getString("foccupation")+"></td> </tr>"); out.println("<tr> <td><p>Salary (per month) </p></td> <td>:</td> <td><input type=text name='fsalary' value="+rs.getString("fsalary")+"></td> </tr>"); out.println("<tr> <td>Address</td> <td>:</td> <td><textarea name='faddress'>"+rs.getString("faddress")+"
Ads