惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 逝者如斯(乎)

Redis和Memcached的区别详解 分布式系统原理与范型 - 电子支付系统 CSS3 (1) - Beginner Shell Script (2) - global.sh Python (1) - 7 Steps to Mastering Machine Learning With Python Master Nginx(8) - Troubleshooting Techniques Master Nginx(7) - Nginx for the Developer Master Nginx(6) - The Nginx HTTP Server Hadoop实战课程 Java EE (14) -- SSH配置 Self-Paced Training (3) - Docker Operations Self-Paced Training (2) - Docker Fundamentals Self-Paced Training (1) - Introduction to Docker Shell Script Tutorials (0 ~ 62) Master Nginx(5) - Reverse Proxy Advanced Topics Master Nginx(4) - Nginx as a Reverse Proxy Master Nginx(3) - Using the Mail Module Mater Nginx(2) - A Configuration Guide Master Nginx(1) - Installing Nginx and Third-Party Modules
Java面试题(1)- 高级特性
逝者如斯(乎) · 2016-10-07 · via 博客园 - 逝者如斯(乎)

Most Top 6 Struts 2 interview questions and answers for Experienced
1. Struts 2 Architecture Flow

-> 1. When the application server get started, the container loads the web.xml file.

-> 2. When the first request if made from the client browser to the server with a particular URL, the control first reaches web.xml file. It checks mapping for URL in web.xml and finds the Filter Dispatcher.

-> 3. The Filter Dispatcher determine whether to invoke an Action or not using the Action mapper and delegates the control to the Action Proxy.

-> 4. The ActionProxy takes help from Configuration Manager, which is initialized from the struts.xml. The the ActionProxy creates an ActionInvocation.

-> 5. The ActionInvocation finds which Action class to invoke for this request and discovers the intereptors associataed with the action mapping.

-> 6. ActionInvocation now invokes the intercept() method of the first interceptor in the stack. After execution of first interceptor Invoke() will check for the next interceptor.

-> 7. After the execution of all the interceptors the action class will be invoked. Finally a result string will be returned and the corresponding view will be rendered.


2. Difference Between Struts 1.x and Struts 2.x ?

 

3. What is Interceptors ?

Interceptor is an object that is invoked at the preprocessing and post processing of a request. In struts 2, interceptor is used to perform operations such as validation, exception handling, internationalization, displaying intermediate result etc.

4. What is Value Stack and OGNL?

Value Stack is the storage area where the application data is stored by Struts 2 for processing the client requests. The data is stored in ActionContext objects that use ThreadLocal to have values specifc to the particular request thread.

Object-Graph Navigation Language (OGNL) is a powerful Expression Language that is used to manipulate data stored on the ValueStack. As you can see in architecture diagram, both interceptors ans result pages can access data stored on ValueStack using OGNL.

5. Does Struts2 action and interceptors are thread safe?

Struts 2 Action classes are thread safe because an object is instantiated for every request to handle it.

Struts 2 interceptors are singleton classes and a new thread is created to handle the request, so it's not thread safe, we need to implement them carefully to avoid any issues with shared data.

6. What is Action Context and Action Invocation?

The ActionContext is a container of objects in which action is executed. The values stored in the ActionContext are unique per thread(i.e. ThreadLocal). So we don't need to make our action thread safe.

We can get the reference of ActionContext by calling the getContext() method of ActionContext class. It is a static factory method. For example:
ActionContext ctx = ActionContext.getContext();

The ActionInvocation represents the execution state of an action. It holds the action and interceptors objects.

The struts framework provides ActionInvocation interface to deal with ActionInvocation. It provides many methods, some of them can be used to get the instance of ValueStack, ActionProxy, ActionContext, Result etc.

===============================================================

1. The diffrence between java.lang.StringBuffer and java.lang.StringBuilder?

java.lang.StringBuffer: thread-safe, synchronized and not so faster.

java.lang.StringBuilder: faster, performs no synchronization.

2. How to handle uncaught Exception for a thread?

@FunctionalInterface
public static interface Thread.UncaughtExceptionHandler

3. The difference between [checked exceptions] and [unchecked exceptions]?

The class Exception and any subclasses that are not also subclasses of RuntimeException are checked exceptions. Checked exceptions need to be declared in a method or constructor's throws clause if they can be thrown by the execution of the method or constructor and propagate outside the method or constructor boundary.

Checked Exceptions should be used for expected, but unpreventable errors that are reasonable to recover from.

4. How to use non static innner class and static inner class?

non static: Out.In in = new Out().new In();

static: Out.StaticIn in = new Out.StaticIn();

5. Anonymous Inner Class? 

Anonymous inner class must extends a super class or implements an interface.

ClassA a = new ClassA();

a.test(new Product(){

  public double process() {

  }

});

6. How to create dynamic proxy class and dynamic proxy instance?

java.lang.reflect.Proxy
interface InvocationHandler

static Class<?> getProxyClass(ClassLoader loader, Class<?>... interfaces)
static Object newProxyInstance(ClassLoader loader, Class<?>[] interfaces, InvocationHandler h)

InvocationHandler handler = new MyInvocationHandler(...);

Class proxyClass = Proxy.getProxyClass(Foo.class.getClassLoader(), new Class[] { Foo.class });
Constructor ctor = proxyClass.getConstructor(new Class[] { InvocationHandler.class });
Foo f = (Foo)ctor.newInstance(new Object[] { handler });

Foo f = (Foo)Proxy.newProxyInstance(Foo.class.getClassLoader(), new Class[] { Foo.class }, handler);

7. What's the difference between 3 types of class loaders?

public abstract class ClassLoader extends Object

loadClass(String name, boolean resolve)

findClass(String name)

Bootstrap ClassLoader: load core classes of Java. (java.exe -Xbootclasspath can load additional class). Not a subclass of java.lang.ClassLoader.

jre/lib/*.jar

jre/classes

Extension ClassLoader: jre/lib/ext/* or defined by java.ext.dirs System Property.

System ClassLoader: java -classpath or defined by java.class.path

java.lang.Object
  java.lang.ClassLoader
    java.security.SecureClassLoader
      java.net.URLClassLoader

Parents of Extension ClassLoader and System ClassLoader.

8. How does interface Serializable works?

All subtypes of a serializable class are themselves serializable.

Classes that require special handling during the serialization and deserialization:

private void writeObject(java.io.ObjectOutputStream out) throws IOException
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException;
private void readObjectNoData() throws ObjectStreamException;

Designate an alternative object to be used when writing an object to the stream:

ANY-ACCESS-MODIFIER Object writeReplace() throws ObjectStreamException;

Designate a replacement when read from the stream:

ANY-ACCESS-MODIFIER Object readResolve() throws ObjectStreamException;

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;

9. How does Buffer works?

java.nio.Buffer
capacity is the number of elements it contains.
limit is the index of the first element that should not be read or written.
position is the index of the next element to be read or written.
mark is the index to which its position will be reset when the reset method is invoked.

0 <= mark <= position <= limit <= capacity

clear() sets the limit to the capacity and the position to zero.

flip() sets the limit to the current position and then sets the position to zero.

rewind() leaves the limit unchanged and sets the position to zero.

Buffers are not safe for use by multiple concurrent threads.

b.flip().position(23).limit(42);

10. The difference between interfaces of runnable and callable<v>?

callable can have return value.

11. The difference between java.util.Collections and interface Map<K,V>?

Collections contains only items while Map contains key-value pairs.

12. The difference between interface Set<E> (java.util.HashSet<E>) and interface List<E> (java.util.ArrayList<E>)?

Unordered and No-duplicated for Set<E>, Ordered and duplicated for List<E>.

13. The difference between HashSet, TreeSet and EnumSet?

14. The difference between HashTable, HashMap, EnumMap and TreeMap?

Non thread safe, key and value can be null for HashMap.

Thread safe, key and value can't be null for HashTable.