/* * @(#)SampleBean.java 1.3 97/11/19 * * Copyright (c) 1995-1997 Sun Microsystems, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of Sun * Microsystems, Inc. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Sun. * * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING * THIS SOFTWARE OR ITS DERIVATIVES. */ import javax.servlet.http.*; import java.io.PrintWriter; import java.io.IOException; public class SampleBean extends HttpServlet { String stringProperty = "Hello World"; int intProperty = 0; public void doGet(HttpServletRequest req, HttpServletResponse res) throws IOException { // Set response headers: res.setContentType("text/html"); res.setHeader("Cache-Control", "private"); // Emit current properties setting: PrintWriter writer = res.getWriter(); writer.println("SampleBean"); writer.println("

SampleBean current configuration:"); writer.println(""); writer.println(""); writer.println(""); writer.println("
PropertyValue
stringProperty"+getStringProperty()); writer.println("
intProperty"+getIntProperty()); writer.println("
"); writer.println("

Go to the admin to change these bean properties !"); writer.println(""); } /** * Bean property accessor - Get the stringProperty value. * @return A String instance, or null */ public String getStringProperty() { return stringProperty; } /** * Bean property accessor - Set the stringProperty value. * @param A String instance, or null */ public void setStringProperty(String stringProperty) { this.stringProperty = stringProperty; } /** * Bean property accessor - Get the intProperty value. * @return The integer value for the property. */ public int getIntProperty() { return intProperty; } /** * Bean property accessor - Set the intProperty value. * @return The new value for that property */ public void setIntProperty(int intProperty) { this.intProperty = intProperty; } }