Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: JSP Servlet
Delete.jsp
<body>
<form >
<% User u = (User)session.getAttribute("modifiedUserInfo"); 
out.println(u);
session.removeAttribute("u");
if (u != null)
    out.print(u);
%>
</form>
</body>
User is a pojo class.
 
ModifyUser.java(Servlet class)
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			
    User user = new User();
    HttpSession session = request.getSession(true);
		
    user.setFirstName(request.getParameter("FirstName"));
    user.setLastName(request.getParameter("LastName"));
    user.setUserId(request.getParameter("UserId"));
				
    session.setAttribute("modifiedUserInfo",user);
    response.sendRedirect("EditedDetails.jsp");
}
Im not able to delete the data stored in session and getting error as "An exception occurred processing JSP page". What changes has to be done in the code?
Posted 6-Jun-13 3:28am
Edited 6-Jun-13 4:39am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hello Shruthi,
 
Change your jsp code as shown below.
<%@ page contentType="text/html;charset=utf-8" language="java" %>
<%@ page import="com.foo.User"%>
<html>
<head></head>
<body>
<form>
<% User u = (User) session.getAttribute("modifiedUserInfo"); 
session.removeAttribute("modifiedUserInfo");
if (u != null)
    out.print(u.getFirstName() + u.getLastName());
%>
</form>
</body>
</html>
Please change import declaration to match the package of User class in above sample(Second line).
 
You were probably getting error because of this missing import. Also you were removing wrong (probably non-existing) session attribute, you should have removed session attribute named modifiedUserInfo and not u.
 
Regards,
  Permalink  
v3

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

  Print Answers RSS
0 OriginalGriff 325
1 DamithSL 300
2 Sergey Alexandrovich Kryukov 289
3 CPallini 235
4 Maciej Los 215
0 OriginalGriff 5,455
1 DamithSL 4,422
2 Maciej Los 3,860
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,010


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 6 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100