this is my code block to get the updated values
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h3>Updated Successfuly!!</h3>
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mysql"
user="root" password="root"/>
<sql:update dataSource="${snapshot}" var="result">
UPDATE user_reg_ml SET uname=${param.uname} ,email=${param.email} ,country=${param.country} where id=${param.id}
</sql:update>
<%--
<sql:query var="result" dataSource="${snapshot}">
select * from user_reg_ml where id=${param.id}
</sql:query>
<table>
<c:forEach var="row" items="${res.rows}">
<tr>
<td>
ID
</td>
<td>
${row.id}
</td>
</tr>
<tr>
<td>
Name
</td>
<td>
${row.uname}
</td>
</tr>
<tr>
<td>
Email
</td>
<td>
${row.email}
</td>
</tr>
<tr>
<td>
Country
</td>
<td>
${row.country}
</td>
</tr>
</c:forEach>
</table>
--%>
</body>
</html>
and this is my code block to edit values
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
Welcome ${uname}
<form action="update_mypage.jsp" method="post">
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mysql"
user="root" password="root"/>
<sql:query dataSource="${snapshot}" var="result">
select * from user_reg_ml where uname='${param.uname}' and pwd='${param.pwd}'
</sql:query>
<%----%>
<c:forEach var="row" items="${result.rows}">
ID: <input type="text" name="id" value="${row.id}" ><br/>
USERNAME: <input type="text" name="uname" value="${row.uname}"><br/>
EMAIL: <input type="text" name="email" value="${row.email}"><br/>
COUNTRY: <input type="text" name="country" value="${row.country}"><br/>
</c:forEach>
<input type="submit" value="update">
</form>
</body>
</html>
but when i click update button, i get following error
HTTP Status 500 - Internal Server Error
type Exception report
messageInternal Server Error
descriptionThe server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException:
UPDATE user_reg_ml SET uname=abc ,email=abc@gmail.com ,country=India where id=1
: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com ,country=India where id=1' at line 1
root cause
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@gmail.com ,country=India where id=1' at line 1
note The full stack traces of the exception and its root causes are available in the GlassFish Server Open Source Edition 4.0 logs.