Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ J2EE Example of Filter     - Dialogue UNIX:! $ # @ *% (Linux)

- Linux garbled file delete method (Linux)

- Error: Unable to establish connection with FTP SFTP server (Server)

- A drop datafile Oracle bug (Database)

- GRUB how to load Linux kernel (Linux)

- Mhddfs: multiple smaller partitions into one large virtual storage (Linux)

- After CentOS configure SSH password Free, still prompted for a password (Linux)

- Ansible module Know (Linux)

- By creating a personal technology blog Detailed GitHub (Linux)

- Ubuntu 13.04 configure MyEclipse 10.7 Environment (Linux)

- Ubuntu 14.04 and derivative version of the user on how to install cURL 7.37.1 (Linux)

- Ubuntu Tutorial: E: Failed to get lock / var / lib / apt / lists / lock - open (Linux)

- Linux some lessons learned about network security (Linux)

- Upgrading KDE Plasma 5.3 in Ubuntu 15.04 (Linux)

- CentOS set up FTP server (Server)

- Get the Linux device PCI ID method (Linux)

- Linux Shell introduces (Linux)

- Fast Learning Clojure (Programming)

- Xshell key authentication mechanism using a remote login Linux (Linux)

- Linux Apache server configure to protect system security (Linux)

 
         
  J2EE Example of Filter
     
  Add Date : 2018-11-21      
         
         
         
  Javax.servlet.Filter class has three main methods.

public void destroy (); // destroy the object
public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain); Filter response code // write In this method
public void init (FilterConfig fConfig); // initialize objects

First create a web project, the establishment of two JSP pages, and the procedure main article on the use of the death doFilter () method, to jump from index1.jsp index2.jsp.

Establish good index1.jsp page and index2.jsp.

Click WEB.xml following configuration, configuration WEB.xml the Servlet Filter and configuration as the class name and class package, then the map is very simple.

< Filter>
  < Filter-name> filter < / filter-name>
  < Filter-class> com.Filter < / filter-class>
  < / Filter>
  < Filter-mapping>
  < Filter-name> filter // should be consistent with the above filter-name
  < Url-pattern> *. Action // Any .action end of the page request can be returned to the filter
  < / Filter-mapping>

Then index1.jsp page, just write a

Click here to jump caused index2.jsp

Test whether you can successfully jump, index2.jsp content easily (this is my page!).

Next is the configuration package com Filter class doFilter () method. Specific code as follows:

HttpServletRequest req = (HttpServletRequest) request;
        String path = req.getServletPath (); // This method only HttpServletRequest class has to obtain a path to the page response
        System.out.println (path);
        if ( "/ forward.action" .equals (path)) {// If they are consistent with the jump in href index1.jsp the address index2.jsp
            request.getRequestDispatcher ( "index2.jsp") forward (request, response).;
        } Else {// if not jump index3.jsp page
            request.getRequestDispatcher ( "index3.jsp") forward (request, response).;
        }
        
        chain.doFilter (request, response);

the above.
     
         
         
         
  More:      
 
- Zookeeper Rights Management and Quota Management (Server)
- Linux user login and IP restrictions (Linux)
- Detailed driver compiled into the Linux kernel (Programming)
- Xtrabackup creates a slave node without downtime (Database)
- Linux script commands - terminal recorder (Linux)
- Mybatis + binding Struts2: achieving user to insert and find (Programming)
- Linux Security and Optimization (Linux)
- Oracle 11g to create a second instance on Linux (Database)
- Linux User Rights Study Notes (Linux)
- Java Concurrency - multiple threads of HelloWorld (Programming)
- Linux iptables firewall settings whitelist (RHEL 6 and CentOS 7) (Linux)
- DRBD rapid installation and deployment (Server)
- Docker study notes (Server)
- Zabbix API and PHP configuration (Server)
- Spacewalk remove packages install the update (Linux)
- File encryption and decryption of Linux security mechanisms (Linux)
- Mongo-connector integrated MongoD to achieve incremental Solr index (Server)
- Four levels to deal with Linux server attacks (Linux)
- Linux device driver development small example --LED lights (Programming)
- Network Security Basics Linux command (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.