Sun River
Topics about Java SE, Servlet/JSP, JDBC, MultiThread, UML, Design Pattern, CSS, JavaScript, Maven, JBoss, Tomcat, ...
posts - 78,comments - 0,trackbacks - 0

1). What is a document type definition and what is its purpose in XML? Explain the difference between a well-formed and a valid XML document.
Answer: The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. A DTD can be declared inline in your XML document, or as an external reference. Two definitions:
   -).A well-formed file is one that obeys the general XML rules for tags: tags must be properly nested, opening and closing tags must be balanced, and empty tags must end with '/>'.
   -). A valid file is not only well-formed, but it must also conform to a publicly available DTD that specifies which tags it uses, what attributes those tags can contain, and which tags can occur inside which other tags, among other properties.

2). External DTD:
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">

3). Minimal but Complete XSLT  Stylesheet

<?xml version="1.0"?>

   < xsl:stylesheet version="1.0"

            xmlns:xsl="http://www.w3.org/1999/ XSL/Transform">

< /xsl:stylesheet >

4). Using XSLT, how would you extract a specfic attribute from an element in an XML document?
Ans: Extract attributes from XML data
   <xsl:template match="element-name">
     Attribute Value:
        <xsl:value-of select="@attribute" />
         <xsl:apply-templates/>
    </xsl:template>

5). Templates--Controls which output is created from which input

--" xsl:template element form

--" match attribute contains an Xpath expression (Xpath expression identifies input node set it matches)

--" For each node in the node set, the

template contents (things between xsl:template tags) are instantiated and inserted into the output tree.

6). Attributes

In the DTD, XML element attributes are declared with an ATTLIST declaration. An attribute declaration has the following syntax:

<!ATTLIST element-name attribute-name attribute-type default-value>

As you can see from the syntax above, the ATTLIST declaration defines the element which can have the attribute, the name of the attribute, the type of the attribute, and the default attribute value.

The attribute-type can have the following values:

ValueExplanation
CDATA
The value is character data
(eval|eval|..)
The value must be an enumerated value
ID
The value is an unique id 
IDREF
The value is the id of another element
IDREFS
The value is a list of other ids
NMTOKEN
The value is a valid XML name
NMTOKENS
The value is a list of valid XML names
ENTITY
The value is an entity 
ENTITIES
The value is a list of entities
NOTATION
The value is a name of a notation
xml:
The value is predefined

The attribute-default-value can have the following values:

ValueExplanation
#DEFAULT value
The attribute has a default value
#REQUIRED
The attribute value must be included in the element
#IMPLIED
The attribute does not have to be included
#FIXED value
The attribute value is fixed


Attribute declaration example

DTD example:
<!ELEMENT square EMPTY>
  <!ATTLIST square width CDATA "0">

XML example:
<square width="100"></square>

In the above example the element square is defined to be an empty element with the attributes width of  type CDATA. The width attribute has a default value of 0. 

Default attribute value

Syntax:
<!ATTLIST element-name attribute-name CDATA "default-value">

DTD example:
<!ATTLIST payment type CDATA "check">

XML example:
<payment type="check">

Specifying a default value for an attribute, assures that the attribute will get a value even if the author of the XML document didn't include it.

Implied attribute

Syntax:
<!ATTLIST element-name attribute-name attribute-type #IMPLIED>
DTD example:
<!ATTLIST contact fax CDATA #IMPLIED>

XML example:
<contact fax="555-667788">

Use an implied attribute if you don't want to force the author to include an attribute and you don't have an option for a default value either. 

Required attribute

Syntax:
<!ATTLIST element-name attribute_name attribute-type #REQUIRED>
DTD example:
<!ATTLIST person number CDATA #REQUIRED>

XML example:
<person number="5677">

Use a required attribute if you don't have an option for a default value, but still want to force the attribute to be present.

Fixed attribute value

Syntax:
<!ATTLIST element-name attribute-name attribute-type #FIXED "value">
DTD example:
<!ATTLIST sender company CDATA #FIXED "Microsoft">


XML example:
<sender company="Microsoft">

Use a fixed attribute value when you want an attribute to have a fixed value without allowing the author to change it. If an author includes another value, the XML parser will return an error.

Enumerated attribute values

Syntax:
<!ATTLIST element-name attribute-name (eval|eval|..) default-value>
DTD example:
<!ATTLIST payment type (check|cash) "cash">

XML example:
<payment type="check">
or
<payment type="cash">
posted @ 2006-11-27 00:48 Sun River| 编辑 收藏
1. Explain what is EJB?
2. what is manditory parts of EJB?
3. What is 4 transaction isolation levels of JDBC?
4. Explain dirty read, nonrepeatable read and phantom read?
5. Give the steps using websphere to develop the ejb application (code change, ejb deploy, servlet etc.)
6. Give the architecture of a SOA application and explain every parts
7. What is JSP model 1 and model 2?
8. Explain the connection pooling
posted @ 2006-11-22 09:52 Sun River| 编辑 收藏
DD
The general procedure for deploying J2EE-based EJB applications assumes the following general steps:
  1. Set J2EE server environment variables—Environment variables must be set for running a J2EE server environment and vary per vendor implementation and operating-system platform.

  2. Configure J2EE server properties—Configuration properties for most J2EE server implementations can be set to suit your particular network and operating environment.

  3. Compile J2EE EJB application code—All J2EE EJB implementation, home, remote, and dependent utility code must be compiled using a standard Java compiler.

  4. Create a J2EE EJB application deployment descriptor—An XML-based deployment descriptor is created according to the EJB application DTD. Some vendor products can create this file for you from a GUI-based configuration tool.

  5. Create vendor-specific deployment descriptors—Because no standard means exists to bind J2EE standard EJB reference names to a J2EE server's JNDI-based naming service, a vendor-specific deployment descriptor mechanism is required to perform this mapping. This deployment descriptor must map EJB reference names used by J2EE components to the actual JNDI names associated with EJB home interfaces. Other vendor-specific properties may also be set for customizing both session and entity beans. Vendors may provide a GUI-based means to configure these files.

  6. Package J2EE EJB application code—The EJB deployment descriptors, all compiled J2EE EJB implementation classes, all compiled J2EE EJB implementation interfaces, and all other compiled classes dependent on your EJBs need to be packaged into an EJB JAR file with a .jar extension. J2EE-based products might supply command-line or GUI-based utilities for this purpose.

  7. Start the J2EE server—The J2EE-compliant server must generally be started at this stage. The exact mechanism for starting a server is often vendor-dependent but can be as simple as invoking a single startup command from the command line.

  8. Create a J2EE application deployment descriptor—A J2EE application deployment descriptor must be created to collect one or more Web, EJB, and application client modules into a cohesive J2EE application. Many products will create this file for you automatically or via a GUI-based configuration tool.

  9. Package J2EE application code—The application and JNDI mapping deployment descriptor, Web applications, EJB applications, and application clients need to be packaged into an enterprise archive (EAR) file with an extension of .ear. Many products also create this archive for you automatically or via GUI-based development tools.

  10. Deploy the J2EE enterprise application code—Finally, the integrated J2EE application is deployed to the J2EE server environment for access by enterprise application clients. This step is also often automated via GUI tools. http://e-docs.bea.com/wls/docs61/webapp/webappdeployment.html

posted @ 2006-11-16 15:01 Sun River| 编辑 收藏

Spring 中的 AOP 简单使用

   

    AOP 作为 Spring 这个轻量级的容器中很重要的一部分,得到越来越多的关注, Spring Transaction 就是用 AOP 来管理的,今天就通过简单的例子来看看 Spring 中的 AOP 的基本使用方法。

 

  首先确定将要 Proxy 的目标,在 Spring 中默认采用 JDK 中的 dynamic proxy ,它只能够实现接口的代理,如果想对类进行代理的话,需要采用 CGLIB proxy 。显然,选择 编程到接口 是更明智的做法。

 

下面是将要代理的接口:

public interface FooInterface {
    public void printFoo();
    public void dummyFoo();
}

以及其一个简单的实现:
public class FooImpl implements FooInterface {
    public void printFoo() {
        System.out.println("In FooImpl.printFoo");

    }

    public void dummyFoo() {
        System.out.println("In FooImpl.dummyFoo");
    }
}
 
接下来创建一个 Advice ,在 Spring 中支持 Around,Before,After returning Throws 四种 Advice ,这里就以简单的 Before Advice 举例:
 
public class PrintBeforeAdvice implements MethodBeforeAdvice {
    public void before(Method arg0, Object[] arg1, Object arg2) throws Throwable {
        System.out.println("In PrintBeforeAdvice");
    }

}
 
有了自己的 business interface advice ,剩下的就是如何去装配它们了,首先利用 ProxyFactory 以编程方式实现,如下:
 

public class AopTestMain {
    public static void main(String[] args) {
        FooImpl fooImpl = new FooImpl();
        PrintBeforeAdvice myAdvice = new PrintBeforeAdvice();
     
        ProxyFactory factory = new ProxyFactory(fooImpl);
        factory.addBeforeAdvice(myAdvice);
        FooInterface myInterface = (FooInterface)factory.getProxy();

        myInterface.printFoo();
        myInterface.dummyFoo();
    }

}
 
 
现在执行程序,神奇的结果就出现了:
 
  In PrintBeforeAdvice
  In FooImpl.printFoo
  In PrintBeforeAdvice
  In FooImpl.dummyFoo
 
  
虽然这样能体会到 Spring AOP 的用法,但这决不是值得推荐的方法,既然使用了 Spring ,在 ApplicationContext 中装配所需要 bean 才是最佳策略,实现上面的功能只需要写个简单的 applicationContext 就可以了,如下:
 
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "
http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
    <description>The aop application context</description>
    <bean id="fooTarget" class="FooImpl"/>
    <bean id="myAdvice" class="PrintBeforeAdvice"/>
    <bean id="foo" class="org.springframework.aop.framework.ProxyFactoryBean">
     <property name="proxyInterfaces">
       <value>FooInterface</value>
     </property>
     <property name="target">
       <ref local="fooTarget"/>
     </property>
     <property name="interceptorNames">
       <list>
         <value>myAdvice</value>
       </list>
     </property>
    </bean>

</beans>

 

   当然, main 中的代码也要进行相应的修改:
    
public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new 
             ClassPathXmlApplicationContext("applicationContext.xml");
    FooInterface foo = (FooInterface)context.getBean("foo");
    foo.printFoo();
    foo.dummyFoo();
}
 
  
现在运行一下,结果将和上面的运行结果完全一样,这样是不是更优雅?当需要更改实现时,只需要修改配置文件就可以了,程序中的代码不需任何改动。
 
  
但是,这时候会发现被 proxy object 中的所有方法调用时都将运行 advice 中的 before ,这显然不能满足绝大多数情况下的需要,此时,只 需借用 Advisor 就可以了,当然要在 Advisor 中利用 pattern 设置好哪些方法需要 advice ,更改 applicationContext 如下:
 
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "
http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
    <description>The springeva application context</description>
    <bean id="fooTarget" class="FooImpl"/>
    <bean id="printBeforeAdvice" class="PrintBeforeAdvice"/>
    <bean id="myAdvisor"
          class="org.springframework.aop.support.RegexpMethodPointcutAdvisor">
      <property name="advice">
        <ref local="printBeforeAdvice"/>
      </property>
      <property name="pattern">
        <value>.*print.*</value>
      </property>
    </bean>
    <bean id="foo" class="org.springframework.aop.framework.ProxyFactoryBean">
      <property name="proxyInterfaces">
        <value>FooInterface</value>
      </property>
      <property name="target">
        <ref local="fooTarget"/>
      </property>
      <property name="interceptorNames">
        <list>
          <value>myAdvisor</value>
        </list>
      </property>
    </bean>
</beans>

 

    主程序不需进行任何修改,运行结果已经变样了

   In PrintBeforeAdvice
    In FooImpl.printFoo
    In FooImpl.dummyFoo
 
  
至此,应该已经理解了 Spring AOP 的使用方法,当然 Spring AOP 最重要的应用是 Transaction Manager ,举个这方面的 applicationContext 例子看看:
 
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "spring-beans.dtd">

<beans>
    <bean id="propertyConfigurer"   
         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="location">
        <value>/WEB-INF/jdbc.properties</value>
      </property>
    </bean>
    <bean id="dataSource"
          class="org.springframework.jdbc.datasource.DriverManagerDataSource">
      <property name="driverClassName">
        <value>${jdbc.driverClassName}</value>
      </property>
      <property name="url">
        <value>${jdbc.url}</value>
      </property>
      <property name="username">
        <value>${jdbc.username}</value>
      </property>
      <property name="password">
        <value>${jdbc.password}</value>
      </property>
    </bean>
    <bean id="sessionFactory"
          class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
      <property name="dataSource">
        <ref local="dataSource"/>
      </property>
      <property name="mappingResources">
        <value>smartmenu.hbm.xml</value>
      </property>
      <property name="hibernateProperties">
        <props>
          <prop key="hibernate.dialect">${hibernate.dialect}</prop>
        </props>
      </property>
    </bean>
 
    <bean id="transactionManager"       
          class="org.springframework.orm.hibernate.HibernateTransactionManager">
      <property name="sessionFactory">
        <ref local="sessionFactory"/>
      </property>
    </bean>
    <bean id="smartmenuTarget" class="SmartMenuHibernate">
      <property name="sessionFactory">
        <ref local="sessionFactory"/>
      </property>
    </bean>
    <bean id="smartMenu"
        class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
      <property name="transactionManager">
        <ref local="transactionManager"/>
      </property>
      <property name="target">
        <ref local="smartmenuTarget"/>
      </property>
      <property name="transactionAttributes">
        <props>
          <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
          <prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
        </props>
      </property>
    </bean>
  </beans>
 
 
要想彻底理解 Spring AOP ,最好还是多看看源码,开源就是好啊!

 

 

 

posted @ 2006-11-16 13:29 Sun River| 编辑 收藏

J2EE 五层逻辑模型和常见 Framework

 

 

                      ————————————————

                      |                          客户端层                     |        用户交互, UI 实现

                      | Browser,WirelessDevice,WebService |    Http, Soap 协议 (SOP 体系 )

                      ————————————————

 

                      ————————————————

                      |                             表现层                       |   集中登录,会话管理

                      | Struts,Jsf,Webwork,Tapstry, Velocity | 内容创建,格式,传送

                      ————————————————

 

                       ————————————————

                       |                       业务服务层                     |   业务逻辑 , 事务 , 数据 , 服务

                       | SessionEJB Spring Jdoframework) | SessionEjb POJO Service

                        ————————————————

 

                       ————————————————

                       |                            集中层                        |  资源适配器,遗留 / 外部系统  

                       |Jms,Jdbc,Connnector,External Service  |        规则引擎,工作流

                       ————————————————

                       ( 持久化 EntityBean,Hibernate,iBatis,Jdo,Dao,TopLink etc.)      

 

                        ————————————————

                        |                           资源层                             | 资源,数据库,外部服务

                        | DataBase,Resource,External Service   | ( 大型主机, B2B 集中系统 )

                        ————————————————

 

当然一个常见典型的 J2EE 系统可能是这样的

 

客户端 —— 表现层 —— 业务层  —— 持久层 —— 数据库   

FireFox + Velocity + Struts + Spring + Hibernate + MySql + Tomcat + Eclipse

我比较习惯用开源产品。强烈支持开源 !! *.*

                                                           

作为一个程序员,常常打交道的是中间层 ( 表现层,业务层,集成层 )

每个层常用的技术简单的介绍如下:


表现层 (Present Tier)


Intercepting Filter ——
用于对请求的预处理和后处理

 

    拦截过滤器拦截输入的请求和输出的响应,并加入了一个过滤器。 Filter 可以通过配置加入和取消 ( 象在 web.xml 中加入 ServletFilter) ,这样多个过滤器还可以不冲突地组合使用。当预处理以及 / 或者 (filter 虽然后 response 参数,但有时候 filter 不做处理 ) 后处理完成后,这组过滤器种的最后一个把控制器交给原来的目标对象。对于 request 来说,这个目标对象通常是前端控制器,但也可能是一个视图。在 Struts 中, Action 的执行方法中参数由 request, response, actionMapping,actionForm 等等组成。而在 Webwork 中, Action 不用去依赖于任何 Web 容器,不用和那些 JavaServlet 复杂的请求( Request )、响应 (Response) 关联在一起。对请求( Request )的参数 (Param) ,可以使用拦截器框架自动调用一些 get() set() 方法设置到对应的 Action 的字段中。所以 Action excute() 方法没有任何参数,也不存在 FormBean 。正是这种拦截器,使得 Action 变得非常简单, Action 不用继承 servlet ,不依赖 servlet 容器,实现了请求响应与 Action 之间的解耦,而且可以很方便的在 action 中不依赖 web 容器进行单元测试。

 

Front Controller —— 集中控制请求处理

 

    前端控制器是一个容器,用来装载表现层的共同处理逻辑 ( 如果不采用这个控制器,逻辑代码就会错误的放在视图里 ) 。控制器负责处理请求,进行内容的获取,安全性,视图管理,导航等操作,并委派一个分配器组件分派视图。

 

Application Controller —— 实现操作和视图管理的集中化,模块化

 

    应用控制器集中了控制,数据获取,视图和命令处理的调用。前端控制器为输入的请求提供了一个集中的访问点和控制器,而应用控制器则负责找出并调用命令,并且还要找出并分派视图。比如 Struts 中的 ActionServlet,Webwork 种的 ServletDispatcher 等。

posted @ 2006-11-16 13:18 Sun River| 编辑 收藏

1). Steps for Building a JMS Sender Application

1.Get ConnectionFactory and Destination object (Topic or Queue) through JNDI         

// Get JNDI InitialContext object

Context jndiContext = new InitialContext();

// Locate ConnectionFactory object via JNDI

TopicConnectionFactory factory =
      (TopicConnectionFactory) jndiContext.lookup("MyTopicConnectionFactory");

// Locate Destination object (Topic or Queue) through JNDI

Topic weatherTopic = (Topic) jndiContext.lookup("WeatherData");

2.Create a Connection                              
                                 
                    
// Create a Connection object from ConnectionFactory object
                                 TopicConnection topicConnection = factory.createTopicConnection();

3.Create a Session to send/receive messages

         // Create a Session from Connection object.

            // 1st parameter controls transaction

            // 2nd parameter specifies acknowledgment type

         TopicSession session =

            topicConnection.createTopicSession (false, Session.CLIENT_ACKNOWLEDGE);

4.Create a MessageProducer (TopicPublisher or QueueSender)

                                          // Create MessageProducer from Session object
                              // TopicPublisher for Pub/Sub
                              // QueueSender for Point-to-Point
                              TopicPublisher publisher =session.createPublisher(weatherTopic);

5.Start Connection
                                                // Until Connection gets started, message flow
                                    // is inhibited: Connection must be started before
                                    // messages will be transmitted.
                                    topicConnection.start();

6.Send (publish) messages
                                    // Create a Message
                                     TextMessage message =session.createMessage();
                                    message.setText("text:35 degrees");
                                    // Publish the message
                                    publisher.publish(message);

7.Close Session and Connection

2). Steps for Building a JMS Receiver Application (non-blocking mode)

1.Get ConnectionFactory and Destination object

(Topic or Queue) through JNDI

2.Create a Connection

3.Create a Session to send/receive messages

4.Create a MessageConsumer (TopicSubscriber or QueueReceiver)

            // Create Subscriber from Session object
            TopicSubscriber subscriber =session.createSubscriber(weatherTopic);

5.
Register MessageListener for non-blocking mode
         WeatherListener myListener= new WeatherListener();
         // Register MessageListener with TopicSubscriber object
         subscriber.setMessageListener(myListener);

6.Start Connection

7.Close Session and Connection

3). Steps for Building a JMS Receiver Application for blocking mode)

1
.Get ConnectionFactory and Destination object (Topic or Queue) through JNDI

2.Create a Connection

3.Create a Session to send/receive messages

4.

Create a MessageConsumer

5.Start Connection

6.

Receive message

7.Close Session and Connection

posted @ 2006-10-30 01:11 Sun River| 编辑 收藏
     摘要:   阅读全文
posted @ 2006-10-28 15:15 Sun River| 编辑 收藏

pageContext - the PageContext object. Provides an API to access various objects including:

    • context - the context for the JSP page's servlet and any Web components contained in the same application.

    • session - the session object for the client.

    • request - the request triggering the execution of the JSP page.

  • pageScope - a java.util.Map that maps page-scoped attribute names to their values.

  • requestScope - a java.util.Map that maps request-scoped attribute names to their values.

  • sessionScope - a java.util.Map that maps session-scoped attribute names to their values.

  • applicationScope - a java.util.Map that maps application-scoped attribute names to their values.

  • param - a java.util.Map that maps parameter names to a single String parameter value (obtained by calling ServletRequest.getParameter(String name)).

  • paramValues - a java.util.Map that maps parameter names to a String[] of all values for that parameter (obtained by calling ServletRequest.getParameterValues(String name)).

  • header - a java.util.Map that maps header names to a single String header value (obtained by calling HttpServletRequest.getHeader(String name)).

  • headerValues - a java.util.Map that maps header names to a String[] of all values for that header.

  • cookie - a java.util.Map that maps cookie names to a single Cookie object. Cookies are retrieved according to the semantics of HttpServletRequest.getCookies(). If the same name is shared by multiple cookies, an implementation must use the FIRST one encountered in the array of Cookie objects returned by the getCookies() method. However, users of the cookie implicit object must be aware that the ordering of cookies is currently unspecified in the servlet specification.

  • initParam - a java.util.Map that maps context initialization parameter names to their String parameter value (obtained by calling ServletContext.getInitParameter(String name)).

Examples:

The request's URI (obtained from HttpServletRequest):

${pageContext.request.requestURI}
					

The value of the numberOfItems property of the session-scoped attribute named cart:

${sessionScope.cart.numberOfItems}
					

The context path:

${pageContext.request.contextPath}
					

The session-scoped attribute named 'profile' (null if not found):

${sessionScope.profile} 
					

The String value of the productId parameter, or null if not found:

${param.productId} 
					

The value of the productId request parameter:

${param["productId"]}
					

The String[] containing all values of the productId parameter, or null if not found:

${paramValues.productId} 
					

A collection's members can be accessed using square brackets as shown by retrieval of the userName parameter from the param object. Members of an array or List can be accessed if the value in square brackets can be coerced to an int.

<html>
	<head><title>Customer Profile for ${param["userName"]}</title></head>
	<body>
		...
	</body>
</html>

					
Maps can be accessed using the dot operator OR square brackets. For example, ${param.userName} is EQUIVALENT to ${param["userName"]}.

The host HTTP attribute:

${header["host"]}
					

Here is an example of accessing a page-scoped object that is called pageColor:

<body bgcolor="${pageScope.pageColor}"> 

					
it is equivalent to:
<body bgcolor="${pageScope['pageColor']}">

					

posted @ 2006-10-16 01:19 Sun River| 编辑 收藏
Web Application Login Authentication
None
Select when no authentication is desired.
HTTP Basic Authentication (RFC 2617)
Select to specify browser authentication.
Realm
Enter the realm string. The web server then authenticates the user in the specified realm.
HTTP Digest Authentication (RFC 2617)
Select to specify digest authentication.
Form-based Authentication
Select to specify user-written HTML form for authentication.
Login Page
Enter an HTML page, JSP page, or HTTP servlet that is used to authenticate the user. The page must return an HTML page containing a FORM that conforms to a specific naming convention. This is done through the <form-login-config> tag in the <login-config> subelement of the generated web.xml file.
Error Page
Enter an HTML page that is sent to a user when authentication fails. This page contains information about the connection failure.
HTTPS Client Authentication (Public Key Certificate)
Select to specify client-side authentication.

Please refer to http://e-docs.bea.com/wls/docs61/webapp/web_xml.html
posted @ 2006-10-10 01:55 Sun River| 编辑 收藏
Identify which attribute scopes are thread-safe:
  1. Local variables Yes, thread-safe
  2. Instance variables
  3. Not thread-safe
    Since a single servlet instance may be handling multiple service requests at any given time.
  4. Class variables
  5. Not thread-safe
    Since multiple servlets and /or service requests may try to access a class variable concurrently.
  6. Request attributes
  7. Yes, thread-safe
    Since the request object is a local variable
  8. Session attributes
  9. Not thread-safe
    Since sessions are scoped at the web application level, hence the same session object can be accessed concurrently by multiple servlets and their service requests
  10. Context attributes
  11. Not thread-safe
    Since the same context object can be accessed concurrently by multiple servlets and their service requests
posted @ 2006-10-08 12:41 Sun River| 编辑 收藏
仅列出标题
共8页: 上一页 1 2 3 4 5 6 7 8 下一页