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 195
1 Afzaal Ahmad Zeeshan 132
2 ProgramFOX 130
3 Maciej Los 105
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,657
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web01 | 2.8.1411022.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