FileDocCategorySizeDatePackage
UpdateProfileAction.javaAPI DocExample2238Tue Feb 28 11:34:06 GMT 2006com.ora.jsp.servlets

UpdateProfileAction

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

Fields Summary
Constructors Summary
Methods Summary
public ActionForwardperform(ActionMapping mapping, ActionForm form, 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.

param
mapping The ActionMapping used to select this instance
param
form The optional ActionForm bean for this request (if any)
param
request The HTTP request we are processing
param
response The HTTP response we are creating
exception
IOException if an input/output error occurs
exception
ServletException if a servlet exception occurs


        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) 
                getServlet().getServletContext().getAttribute("empReg");
            try {
                empReg.saveEmployee(emp);
            }
            catch (SQLException e) {
                throw new ServletException("Database error", e);
            }
        }
	ActionForward nextPage = mapping.findForward("main");
        return nextPage;