Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi can any one help me i am trying to insert in this way
Java
<%@page import="sun.org.mozilla.javascript.internal.EcmaError"%>
<%@page import="com.dryclean.web.controller.DBUtil"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%
Connection con =null;
Statement stmt = null;

try{
	con = DBUtil.getConnection("jdbc:mysql://localhost:3306/","dry_cleaner","com.mysql.jdbc.Driver","root","");

}catch(Exception ex){
	System.out.println(ex.getMessage());
}

try
{
	String insert_employeequery="INSERT INTO employee(user_id, first_name,last_name, PASSWORD,dob, emp_email, emp_phone, education, site_id, dept_id) VALUES ('"+request.getParameter("user_id")+"','"+request.getParameter("f_name")+"','"+request.getParameter("l_name")+"','"+request.getParameter("user_password")+"','"+request.getParameter("dob")+"','"+request.getParameter("email")+"','"+request.getParameter("phone_number")+"','"+request.getParameter("education")+"','"+request.getParameter("site")+"','"+request.getParameter("dept")+"')";
	System.out.println(insert_employeequery);
	stmt=con.createStatement();
	stmt.executeUpdate(insert_employeequery);
}catch(Exception ex){
	System.out.println(ex.getMessage());
}
response.sendRedirect("viewemployees.jsp");

but is showing me this error
HTML
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /admin/employees/addemployee_do.jsp(7,2) Unterminated <% tag
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:132)
	org.apache.jasper.compiler.Parser.parseScriptlet(Parser.java:789)
	org.apache.jasper.compiler.Parser.parseElements(Parser.java:1451)
	org.apache.jasper.compiler.Parser.parse(Parser.java:137)
	org.apache.jasper.compiler.ParserController.doParse(ParserController.java:255)
	org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:170)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:332)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.

Apache Tomcat/6.0.20
Posted
Updated 26-Sep-12 0:37am
v2

1 solution

Well, the error report is stating it perfectly clear: You have an "<%" open tag that you do not close.

Also, I'm not recommending to this the way you do it AT ALL. There's a much better way to do it, using MVC:

  • Have the JSP template with placeholders for fields
  • Have the database get the data you need, and return it
  • Use a servlet to relay the request from the JSP to the DB (Model)
  • When the Model gives you the info, use the servlet (Controller) to format/rearrange/etc. it, and use it to update the information in the JSP accordingly
  • Voila!


    • You may find further reading about this concept by Googling[^]. There's lots of documented examples out there.
 
Share this answer
 
Comments
Khudha Bakhsh Mari 26-Sep-12 6:48am    
first of all i am thanfull to you dear but i am beginner so i dont know about mvc if you have any link please share with me... thanx
Andrei Straut 26-Sep-12 7:04am    
Just click the link I provided you with, you'll find examples there

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900