Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ J2EE Example of Filter     - Linux Desktop allows exceptionally different launch applications (Linux)

- CentOS7 install and configure Nagios (Server)

- After the first remote installation GlassFish Web to remotely access their back office management system error solution appears (Server)

- CentOS7 build GlusterFS (Linux)

- Confrontation dragged Library - Web front-end encryption slow (Linux)

- Python KNN algorithm of actual realization (Programming)

- exp / imp Export Import version of the problem and the ORA-6550 error (Database)

- CentOS minimal network is unavailable resolved (Linux)

- Node.js development environment deployment (Server)

- Linux System Getting Started Learning: In RedHat Linux driver compiled Ixgbe (Linux)

- Linux basic introductory tutorial ---- simple text processing (Linux)

- Good wireless network security information spread in the air (Linux)

- Check the Linux server performance with ten or so commands in a minute (Server)

- Java implementation heap sort (large root heap) (Programming)

- Build RubyMine + Ruby On Rails + MySQL development environment under Windows (Server)

- Linux and SELinux Exploration Program Manager (Linux)

- Linux SVN account password to save your settings (Linux)

- Linux Command Tutorial: Ubuntu apt-get command (Linux)

- Java polymorphic methods inside constructors complete analysis (Programming)

- Linux-based Heartbeat high availability configuration httpd service (Server)

 
         
  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:      
 
- Python variable type (Programming)
- Linux remote landing system (Linux)
- Modify MySQL character encoding under Linux (Database)
- Linux virtual machine settings network, hostname ssh access (Linux)
- Redis logging system (Database)
- RHEL / CentOS / Fedora Install Nagios 4.0.1 (Linux)
- Ubuntu install Vendetta Online 14.04 (Linux)
- High-performance JavaScript reflows and repaints (Programming)
- Detailed use Zabbix monitoring Nginx (Server)
- Oracle table space rename and delete table space (Database)
- MySQL Slave synchronization problem solving (Database)
- Linux character device - user mode and kernel mode data transfer data (Linux)
- A command to install Sublime Text 3 on Manjaro / Archlinux (Linux)
- Ubuntu 15.04 / 14.04 install Ubuntu After Install 2.6 (Linux)
- Camouflage Nginx Web server version to prevent invasion (Linux)
- C ++ why we chose to use the smart pointer (Programming)
- iOS used in the development --UITabBarController tag controller (Programming)
- Gentoo: startx appeared Failed to load module Problem Solving (Linux)
- VMware Workstation virtual machine Ubuntu achieve shared with the host (Linux)
- C ++ complex class of operator overloading (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.