我正在处理注册表格,这里一切正常。但是,我有一个小问题。当我在表单中编辑时,表单的值将在数据库中更新。但是,当我观看我的个人资料时,它仍然只显示旧值。然后,如果我尝试注销,再次登录页面,我正在查看新的值显示在我的个人资料中。那么,可能是什么问题呢?如何在不执行注销和登录操作的情况下获取更新的值?提前谢谢..
编辑细节的servlet代码:
if(formIdentity.equalsIgnoreCase("editdetails"))
{
if (checkboxStatus.equalsIgnoreCase("No"))
{
User user=new User();
System.out.println("in datafile con of servlet...");
try
{
user.setId(Long.parseLong(request.getParameter("userid")));
user.setFirstName(request.getParameter("fname"));
user.setLastName(request.getParameter("lname"));
user.setLocation(request.getParameter("location"));
user.setDateofbirth(request.getParameter("dob"));
user.setEmail(request.getParameter("email"));
user.setDesc(request.getParameter("desc"));
user.setProfession(request.getParameter("profession"));
user.setProjects(request.getParameter("myprojects"));
user.setHobbies(request.getParameter("hobby"));
System.out.println("in try con of servlet...");
userDao.updateUser(user);
response.sendRedirect("Home");
}
catch(Exception e1)
{
e1.printStackTrace();
}
finally
{
userDao.closeSession();
}
}
else if(checkboxStatus.equalsIgnoreCase("Yes"))
{
mpr=new MultipartRequest(request,webTempPath,5*1024*1024, new MnthFileRenamePolicy());
response.setContentType("text/html");
System.out.println("inside editdetails..");
try
{
System.out.println("in datafile con of servlet...");
this.filename=mpr.getFilesystemName("datafile");
File srcFile=new File(webTempPath+this.filename);
mpr.copyFile(srcFile, new File(webTempPath+"signup/"+this.filename));
String imgpath="assets/signup/"+this.filename;
System.out.println("image is=="+imgpath);
System.out.println("After file of servlet...");
User user=new User();
user.setId(Long.parseLong(mpr.getParameter("userid")));
user.setFirstName(mpr.getParameter("fname"));
System.out.println("After fname of servlet..."+mpr.getParameter("fname"));
user.setLastName(mpr.getParameter("lname"));
user.setLocation(mpr.getParameter("location"));
user.setDateofbirth(mpr.getParameter("dob"));
user.setEmail(mpr.getParameter("email"));
user.setProfession(mpr.getParameter("profession"));
user.setHobbies(mpr.getParameter("hobby"));
System.out.println("After email of servlet..."+mpr.getParameter("email"));
user.setDesc(mpr.getParameter("desc"));
user.setImagePath(imgpath);
userDao.updateUser(user);
response.sendRedirect("Home");
}
catch(Exception e1)
{
e1.printStackTrace();
}
finally
{
userDao.closeSession();
}
}