Java Servlet example eclipse

Steps to create Sample Project Using Java Servlets Lets see how to create a sample web application using Java Servlets and widely used Web server TOMCAT in Eclipse. Environment : Eclipse Java EE IDE for Web Developers. Version: Kepler Service Release 1  Server info: Apache Tomcat/7.0.37 Servlet version: 3.0 JSP version: 2.1 Java version: 1.8.0_40 Create a new…

Continue reading

What is Servlet?

Servlet Overview Earlier Common Gateway Interface (CGI) server-side scripts used to generate dynamic content. Disadvantages of CGI Platform dependence Lack of scalability Always a new process should be created to serve a request. i.e. f there are N simultaneous requests to the same CGI program, the code for the CGI program is loaded into memory N times….

Continue reading

Java SE 8 features

Java SE 8 Features Some of the important Java se 8 features are Please click on each link for detailed explanation lambda expressions functional interface foreach method in java.lang.iterable Default methods and Static methods Method References Remaining features will be updated soon ………

Continue reading

Maven

Maven Apache Maven, is an innovative software project management tool, provides new concept of a project object model (POM) file to manage project’s build, dependency and documentation. The most powerful feature is able to download the project dependency libraries automatically. Maven Local Repository is a local folder that is used to store all your project’s…

Continue reading

How to create immutable class in Java?

How to create immutable class in Java? Immutable class is a class which once created, its contents cannot be modified. Immutable objects are the objects whose state cannot be modified once it is created. Best example to explain the difference between mutable and immutable is String and StringBuffer. String is immutable class (Refer String is…

Continue reading

String is immutable or final in Java

String is immutable or final in Java? One of the Interviewers favourite question, How String plays an important role in every program, similarly in every interview questions on String will be there 🙂 😉 . Let’s check the reasons behind why String is immutable of final. Security: String is used in many places like in…

Continue reading

String Pool

Almost in every program, String is being used. When we create a string, it is stored in String pool, as name indicates it is a pool of Strings stored in Java Heap Memory. We can create String in 2 ways By using new operator, String v1 = new String(“Test”); Directly assign the value using Double…

Continue reading

Generics

Generics Java Generics features were introduced from Java Se 5 onwards. Before Java 5, we can store any type of objects in collection i.e. non generic. With inclusion of Generics we need to store only specific type of objects only. Let’s look at the benefits of generics Compile time checking: Generics allows you to check…

Continue reading

Custom Annotation

Custom Annotation Similar to interface we can define Custom Annotations or user defined annotations simply by adding @interface in the declaration. For example: @interface CustomAnnotation{} Here, CustomAnnotationis the custom annotation name. While writing the custom annotations few points has to be considered. Method should not have any throws clauses, Similar to interface only declarations available…

Continue reading

Java se 8 Repeating Annotations

Repeating Annotations ( Java SE 8) In some cases we need to use Repeated Annotations as per the requirement @Retention(RetentionPolicy.RUNTIME) @interface CustomAnnotation { String city() ; int pin() default 123; } @CustomAnnotation(city = “Vijayawda”) @CustomAnnotation(city = “Chennai”) public static void testAnnotation() { System.out.println(“Custom annotation test”); } If you use repeated Annotations like this compiler will…

Continue reading