%-- Document : profile_edit Created on : Feb 13, 2008, 1:06:52 PM Author : aili --%> <%@page contentType="text/html" pageEncoding="UTF-8" import="java.util.*,java.lang.*,java.io.*,pets.beans.*,org.apache.commons.fileupload.*,org.apache.commons.fileupload.disk.DiskFileItemFactory,org.apache.commons.fileupload.servlet.ServletFileUpload,javax.servlet.*" %> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <% boolean isMultipart = ServletFileUpload.isMultipartContent((HttpServletRequest)request); if ( isMultipart ) { // Create a factory for disk-based file items FileItemFactory factory = new DiskFileItemFactory(); // Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); upload.setHeaderEncoding("UTF-8"); try { // Parse the request List items = upload.parseRequest((HttpServletRequest)request); FileItem photoFile = null; String username = ""; String password1 = ""; String password2 = ""; String email = ""; String first_name = ""; String last_name = ""; String lang = ""; String country = ""; String mobile = ""; // Process the uploaded items Iterator iter = items.iterator(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if ( !item.isFormField() && item.getFieldName().equals("profile_photo") && item.getName() != null ) { if ( item.get().length > 0 ) { photoFile = item; } } else if (item.getFieldName().equals("delete_photo")) { photoFile = null; } else { String val = new String(item.get()); val = new String(val.getBytes(), "utf-8"); if ( item.getFieldName().equals("username") ) { username = val; } if ( item.getFieldName().equals("password1") ) { password1 = val; } if ( item.getFieldName().equals("password2") ) { password2 = val; } if ( item.getFieldName().equals("email") ) { email = val; } if ( item.getFieldName().equals("country") ) { country = val; } if ( item.getFieldName().equals("firstname") ) { first_name = val; } if ( item.getFieldName().equals("lastname") ) { last_name = val; } if ( item.getFieldName().equals("language") ) { lang = val; } if ( item.getFieldName().equals("mobile") ) { mobile = val; } } } Boolean hasErrors = profile.saveProfile(request,photoFile,username,password1,password2,email,first_name,last_name,lang,country,mobile); if (!hasErrors) { %><% } } catch (FileUploadException ex) { ex.printStackTrace(); } } %> <%@ include file ="../WEB-INF/jspf/Header.jspf" %> <%@ include file="../WEB-INF/jspf/UserMenu.jspf" %> <%----%> " /> " onClick="window.location.href='profile_view.faces'" /> <%@ include file ="../WEB-INF/jspf/Footer.jspf" %>