ITworld.com
  Search  
ITworld Home Page ITworld Webcasts ITworld White Papers ITworld Newsletters ITworld News ITworld Topics Careers ITworld Voices ITwhirled Changing the way you view IT
Personalize Your Web site with Skins, Part 3
ASP TUTOR --- 07/30/2001

Brian R.J. Heumann

The skin server
Listing 5 contains the core of a basic skin server. The skin server loads a property file that contains mappings of pairs (skin, ID) to files. Each mapping is defined as <skin>.<id>=<file>. The skin server then maps the request parameters to a file name and forwards the request to that file. That file is finally transmitted to the receiver; in this example, the file forwards to the browser that displays the HTML for PersonalHomepage.jsp. 

On this topic

Listing 5: SkinServer.jsp

<%@ page language="Java" import="java.util.*, UserProfileBean" %>

<%-- Load Property bundle --%>
<% Properties props = new Properties(); try { props.load( new FileInputStream( application.getRealPath ("data/skin.properties") ) ) ; } catch( Exception e ) { e.printStackTrace( System.err ) ; } String parameter = request.getParameter( "skin" ) + "." + request.getParameter( "id" ) ; %>

<jsp:forward page="<%=props.getProperty( parameter )%>"/>

In Listing 6, you can see the structure of the properties stored in a property file. For example, a request for the skin blue_ocean's logo element would map to the file data/yourco_blue_ocean.gif.

Listing 6: skin.properties
# -- General Structure --# # .=

#-- Red Whip Skin --#
red_whip.css=/data/red.css red_whip.logo=/data/yourco_red_whip.gif

#-- Blue Ocean Skin --#
blue_ocean.css=/data/blue.css blue_ocean.logo=/data/yourco_blue_ocean.gif

#-- Green Piece Skin --#
green_piece.css=/data/green.css green_piece.logo=/data/yourco_green_piece.gif

Improve Performance
You can improve performance by loading the properties files only once, when the SkinServer JSP loads. For example, you could wrap the properties in a JavaBean, which loads the properties only once and then resides in memory until the JSP unloads.

Performance and file caching are important issues for a scalable Website with a large number of users. Another viable approach to improving performance would be to cache the skin elements in memory and return a character or binary stream for each request.

You should also note that the skin server may become a bottleneck in a distributed Website. In that case, load balancing for a set of skin servers could address the problem.

Customize your Website
Users appreciate it when they can personalize Websites or portals, particularly those sites that they use often. By providing predefined skins, you can give your users a choice regarding the look of your Website without sacrificing its professional design. You start by factoring out the key visual elements and creating different designs for users.

In this article, you learned how users can enter their preferences in a form and how to store user profiles in JavaBeans. You also learned how to use the user profile to display a customized Website with a skin server. You should now have a clear idea of how to add personalization features to your Website. The solution is easy to implement and can easily grow to store more user preferences.

 

Brian R.J. Heumann is a user-centered design consultant at IBM. He has several years of experience working with object-oriented technologies and software development, especially Java, HTML, and JSPs. He develops Websites for e-commerce, presentations, and portals.



Advertisements
Sponsored links
Top 5 Reasons to Combine App Performance and Security
KODAK i1400 Series Scanners stand up to the challenge
Locate Hidden Software on business PCs with this free tool
Bring harmony to your mix of UNIX-Linux-Windows computing environments
 Home   Newsletters  ASP TUTOR
www.itworld.com    open.itworld.com     security.itworld.com     smallbusiness.itworld.com
storage.itworld.com     utilitycomputing.itworld.com     wireless.itworld.com

 
Contact Us   About Us   Privacy Policy    Terms of Service   Reprints  

CIO   Computerworld   CSO   GamePro   Games.net   IDG Connect   IDG World Expo   Industry Standard   Infoworld   ITworld   JavaWorld   LinuxWorld  MacUser   Macworld   Network World   PC World   Playlist  

Copyright © Computerworld, Inc. All rights reserved

Reproduction in whole or in part in any form or medium without express written permission of Computerworld Inc. is prohibited. Computerworld and Computerworld.com and the respective logos are trademarks of International Data Group Inc.