Skip to content

Instantly share code, notes, and snippets.

View jackblack369's full-sized avatar
🚀
get started

Dongwei jackblack369

🚀
get started
View GitHub Profile
@jackblack369
jackblack369 / HSQL in hibernate.java
Created March 4, 2019 04:02
[code-HSQL in hibernate] #hibernate
import java.util.Arrays;
import java.util.List;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import com.journaldev.hibernate.model.Employee;
import com.journaldev.hibernate.util.HibernateUtil;
@jackblack369
jackblack369 / criteria in hibernate.java
Created March 4, 2019 03:59
[code-criteria in hibernate] #hibernate
import java.util.Arrays;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.FetchMode;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.ProjectionList;
@jackblack369
jackblack369 / filter in servlet.md
Last active March 1, 2019 07:10
[learn fliter in servlet] #java #web

A filter is an object that is invoked at the preprocessing and postprocessing of a request.

  • It is mainly used to perform filtering tasks such as conversion, logging, compression, encryption and decryption, input validation etc.
  • The servlet filter is pluggable, i.e. its entry is defined in the web.xml file, if we remove the entry of filter from the web.xml file, filter will be removed automatically and we don't need to change the servlet.

Usage of Filter

  • recording all incoming requests
  • logs the IP addresses of the computers from which the requests originate
@jackblack369
jackblack369 / event and listen.md
Last active March 1, 2019 06:16
[learn-Event and Listen] #java #servlet

Events are basically occurrence of something. Changing the state of an object is known as an event.

We can perform some important tasks at the occurrence of these exceptions, such as counting total and current logged-in users, creating tables of the database at time of deploying the project, creating database connection object etc.

Event classes

  • ServletRequestEvent
  • ServletContextEvent
  • ServletRequestAttributeEvent
  • ServletContextAttributeEvent
@jackblack369
jackblack369 / session tracking.md
Last active March 14, 2019 12:08
[learn session tracking] #java #web

session

Session simply means a particular interval of time. Session Tracking is a way to maintain state (data) of an user. It is also known as session management in servlet.

  • HTTP is stateless that means each request is considered as the new request. It is shown in the figure given below:

  • There are four techniques used in Session tracking:

    • Cookies
@jackblack369
jackblack369 / servlet jsp.md
Last active February 28, 2019 07:45
[learn-Servlet JSP] #java

Web Application

HTML and HTTP

  • HTML:HyperText Markup Language.
  • HTTP:HyperText Transfer Protocol
    • HTTP is the communication protocol between server and client. HTTP runs on top of TCP/IP communication protocol.
    • Port numbers 0 to 1023 are reserved ports for well known services, for example 80 for HTTP, 443 for HTTPS, 21 for FTP etc.
  • Java Servlet and JSPs are server side technologies to extend the capability of web servers by providing support for dynamic response and data persistence.
@jackblack369
jackblack369 / learn-Functional Interfaces.md
Created February 27, 2019 16:15
[learn-Functional Interfaces] #java

Java 8 Functional Interfaces

Being object oriented is not bad, but it brings a lot of verbosity to the program. Java 8 Functional Interfaces and Lambda Expressions help us in writing smaller and cleaner code by removing a lot of boiler-plate code.

  • An interface with exactly one abstract method is called Functional Interface. @FunctionalInterface annotation is added so that we can mark an interface as functional interface.
  • Some of the useful java 8 functional interfaces are Consumer, Supplier, Function and Predicate.

Lambda Expression

  • Objects are the base of java programming language and we can never have a function without an Object, that’s why Java language provide support for using lambda expressions only with functional interfaces.
  • Lambda Expressions syntax is (argument) -> (body).
@jackblack369
jackblack369 / java 8.md
Last active March 1, 2019 07:23
[learn java 8] #java

forEach() method in Iterable interface

default and static methods in Interfaces

  • Java 8 introduces the “Default Method” or (Defender methods) feature, which allows the developer to add new methods to the interfaces without breaking their existing implementation. It provides the flexibility to allow interface to define implementation which will use as the default in a situation where a concrete class fails to provide an implementation for that method.

Functional Interfaces and Lambda Expressions

Java Stream API for Bulk Data Operations on Collections

Java Time API

Collection API improvements

Concurrency API improvements

@jackblack369
jackblack369 / joke.md
Last active March 4, 2019 03:38
[joke] #funny
  • 自从用了网易云,我把《故事会》退订了
  • ¿Why?
@jackblack369
jackblack369 / java tips.md
Created February 26, 2019 08:37
[java snippet tip] #java #snippet
  • public class
public class Main {
 
    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
    public class Test1 {}  //正确
}
public class Test2{}//错误