In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "Servlet 2.4 version features". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. XML Schema Definition Web Query Deployment Description File
Servlet versions prior to 2.3 used a DTD as the definition of the deployment description file, and its web.xml format was as follows:
.......
Servlet version 2.4 *** uses XML Schema definitions as deployment description files, making it easier for Web containers to verify web.xml syntax. XML Schema also provides better extensibility, and its format in web.xml is as follows:
.........
Although the first few lines above show differences between the two versions, Web artifacts in Servlet version 2.4 program web.xml are set up in much the same way as Servlet version 2.3.
2. Servlet Request Listeners
Servlet version 2.4 adds ServletRequest listeners to the event listener, including ServletRequestListener, ServletRequestAttributeListener, and other related classes. These classes can be used to manage and control events related to ServletRequest actions. The following program shows the structure of a typical ServletRequest listener.
import javax.setvlet.ServletContext;
import javax.servlet.ServletRequestListener;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.http.HttpServletRequest;
import iava.io.*;
import java.util.Locale;
public final class RequestListenerimplements
SerVletRequestListener,
ServletRequestAttributeListener,ServletContextListener{
........
public void requestlnitialized(javax.servlet.
ServletRequestEvent event){
........
}
public void attributeAdded(javax.servlet.
ServletRequestAttributeEvent event){
........
}
public void attributeRemoved(javax.servlet.
ServletRequestAttributeEvent event){
........
}
public void attributeReplaced(javax.servlet.
ServletRequestAttributeEvent event){
........
}
public void attributeDestroyed(javax.servlet.
ServletRequestAttributeEvent event){
........
}
}
3. Request Dispatcher Change
Servlet version 2.4 of the Web program enhances the cooperation between filter and request dispatcher so that the filter can conditionally filter Web requests based on the method used by the request dispatcher. Programmers can set the conditions under which filters work by using elements in web.xml (Figure 1 below):
Set filters for elements
◆ The filter takes effect only if the request comes directly from the customer, corresponding to the REQUEST condition.
Only when a request is forwarded to a Web artifact by a request dispatcher using the forward() method (adopted or defined), the corresponding condition is called FORWARD.
Similarly, only when a request is forwarded to a Web artifact by a request dispatcher using the include() method (adopted or defined), the corresponding condition is called INCLUDE.
Only when a request is forwarded to a Web artifact by a request dispatcher using the Error Information Page mechanism is the ERROR condition.
The fifth filter condition can be a combination of the above four conditions.
"Servlet version 2.4 features what" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.