FileDocCategorySizeDatePackage
UpdateProfileAction.javaAPI DocExample1803Thu Jun 28 16:14:16 BST 2001com.ora.jsp.servlets

UpdateProfileAction

public class UpdateProfileAction extends Object implements Action
This class updates a user profile in the Project Billboard application.
author
Hans Bergsten, Gefion software
version
1.0

Fields Summary
private ActionUtils
utils
Constructors Summary
Methods Summary
public voidperform(javax.servlet.http.HttpServlet servlet, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
Updates the projects property of an authenticated user, represented by the "validUser" session attribute, using the EmployeeRegistryBean. This action is only performed for POST requests. Before returning, the client is redirected to the main page, where the new set of projects are displayed.


                                                    
         
             
        if (request.getMethod().equals("POST")) {
            String[] projects = request.getParameterValues("projects");
            if (projects == null) {
                projects = new String[0];
            }
            HttpSession session = request.getSession();
            EmployeeBean emp = 
                (EmployeeBean) session.getAttribute("validUser");
            emp.setProjects(projects);
            EmployeeRegistryBean empReg = (EmployeeRegistryBean) 
                servlet.getServletContext().getAttribute("empReg");
            try {
                empReg.saveEmployee(emp);
            }
            catch (SQLException e) {
                throw new ServletException("Database error", e);
            }
        }
        response.sendRedirect(utils.getShowPageURL(request, "main.jsp"));