Session cookie in Servlet (7), servlet session cookie1. (1). the user outputs the URL address to effectively access a website and perform a series of valid operations on the website. Then, the entire process of closing the browser is called a session.(2) sessions mainly solve how the server stores the private information of each client.(3) There are two main types of sessions:A> Cookie technology [Client te
3. Servlet listener and Servlet listenerAuthor: Zen Lou wangyue (http://www.cnblogs.com/yaoyinglong) 1. ServletConfig and ServletContext 1.1 ServletConfig and ServletContext configuration and use
Some information unrelated to the business logic should not be hard-coded into the program. Generally, it should be placed in ServletConfig or ServletContext.
Configure the ServletConfig and ServletContext paramet
Servlet solves the web page cache problem, servlet web page Cache
(1) Why should we prevent the page caching problem of the browser:
Therefore, pages that do not need to be cached must be non-cached;
The Code is as follows:
Package com. lc. httpTest; import java. io. IOException; import java. io. printWriter; import javax. servlet. servletException; import java
Detailed description of servlet resource path loading (3), detailed description of servlet
1. For the servlet to read the resource file, consider the project file path and the file after the tomcat server is deployed, so be sure to find out the path of the file to be loaded, and consider which method:There are generally three methods:
(1). Use the traditional met
Servlet listener (3): servlet listener
1. What is a servlet listener?
Servlet listeners are also called web listeners. Is a special class in servlet. It can help developers monitor specific events in web applications. For example, creation and destruction of ServletContext,
Servlet Case 1: User Logon, servlet case
Database preparation:
CREATE DATABASE web;USE web;CREATE TABLE users( id INT PRIMARY KEY AUTO_INCREMENT, username VARCHAR(64), PASSWORD VARCHAR(64), email VARCHAR(64) );INSERT INTO users (username,PASSWORD,email) VALUES("tom","123","tom@qq.com"),("lucy","123","lucy@qq.com");View Code
Corresponding User class:
package domain;public class User { priv
1. The ServletConfig interface is used to describe the configuration information of the Servlet itself.The ServletContext interface is used to describe information about an application (a Context configuration in server. xml, that is, a virtual directory.2. Servlet configuration initialization parameters, such:
Copy codeThe Code is as follows:
These initialization parameters can be obtained through this. ge
Servlet Invocation Procedure
1 The browser obtains the host name from the address bar, obtains the host name corresponding IP address, first looks for the host IP address from the windowshosts file, if not, looks for the DNS server to look for the host name corresponding IP address.
2. The browser connects to the server. 3. The browser sends an HTTP request to the server.
4. The server reads the request message. Determine the host name to be accesse
Servlet case 7: jsp technology and cases, servlet case 7 jsp
Jsp running principle:
Create a java file (servlet) based on the jsp file and compile and run it.
The first access will be translated into a servlet and then executed
Three jsp commands:
1. page command: configure the running properties of page translation (
problem
The project requires that the STRUTS2 and servlet coexist, that struts requests are sent to struts, and that the servlet request is sent to the servlet for processing. The current Web.xml file should be a configuration similar to the following:
When the application is requested, STRUTS2 will intercept all requests and will not be able to respond proper
The servlet and JSP specification versions correspond to the relationship:
Servlet Spec Version
JSP version
JSF version
JAVA EE version
Servlet2.3
JSP1.2, JSP1.1
j2ee1.3
Servlet2.4
JSP2.0
JSF1.1
j2ee1.4
Servlet2.5
JSP2.1
JSF1.2, JSF2.0
Java EE5
Servlet3.0
JSP2.2
Jsp + Servlet implement file upload/download file upload (1), servlet File Upload
The file upload and download functions are essential and useful for Java Web.This article uses the famous File Upload Component under Apache.Org. apache. commons. fileupload implementationNext we will first write the first file to upload based on the materials we have recently seen and our own attempts. In the future, we will
Lin Bingwen Evankaka Original works. Reprint please specify the source Http://blog.csdn.net/evankakaThere are three main ways to request forwarding in a servlet:1, Forward: Refers to forwarding, the current request and the response object is saved, to the specified URL processing. Does not indicate a page jump, so the address bar address will not change.2, redirect: Refers to redirect, including two browser requests, the browser according to the URL r
[Servlet] Summary, servlet Summary1 Servlet basics 1.0 inheritance relationships of common Servlet classes
1.1 common Servlet objects
ServletContext: describes the context of the current project.
ServletRequest: browser requests to the server
Request. getParameter ("user
Js|servlet servlet and JSP Knowledge Review (2) servlet base generates HTML servlet tells the browser when to send the next html -Response.setcontenttype ("text/html"); Modify println statement to build a legitimate web page -The print statement applies output to the corresponding HTML tag. Check the generated html-
The specific method is as follows. in the root directory of tomcat, for example, the directory of my server is D: apacheSoftwareFoundationTomcat55 find the webxml file in the conf folder and remove the following servlet and servlet-mapping element annotations: lt; servlet gt; the procedure is as follows: Under the tomcat root directory, for example, if my direc
Solution:
Add a filter before the struts2 filter and forward it to the servlet using the filter.
Web. xml configuration:
Filter Implementation class:
Package filters; import Java. io. ioexception; import Java. util. arraylist; import Java. util. arrays; import javax. servlet. filter; import javax. servlet. filterchain; import javax.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.