Set up the initial global configuration
git config --global user.name "Anshul Sood"
git config --global user.email "anshulsood2006@gmail.com
Get all the configurations
git config --list
Get all the global configurations
git config --global --list
To get the help related to any/all commands
git help config
git help --all
To ignore a file in the git operations add them in .gitignore file e.g.
# ignore all bin directories matches "bin" in any subfolder
bin/
# ignore all target directories
target/
# ignore all files ending with ~
*~
To create a global gitignore to exclude bin folder
cd ~/
touch .gitignore
echo "bin" >> .gitignore
git config --global core.excludesfile ~/.gitignore
Create a git repository
Go to the folder
git init
Get the current status of git repository
git status
Add the file to staging area
git add file1 file2 file3
git all .
Commit files to local repository
git commit -m "Commit Message"
To get history
git log
To show the changes
git show
To revert the changes to a file
git checkout file1
To add to the remote repository
Create a repository on github and copy the URL
git remote add origin "https://github.com/anshulsood2006/Documentation.git"
git push origin {branchName}
If getting error
remote origin already exists
git remote rm origin
Updates were rejected because the tip of your current branch is behind
git pull https://github.com/anshulsood2006/Documentation.git {branchName}
refusing to merge unrelated histories
git merge origin/{branchName} --allow-unrelated-histories
To create a branch
git branch {branchName}
To go to the branch
git checkout {branchName}
To add brancb to remote
git push origin testing
To delete a branch
git branch -D {branchName}
To get the difference from the commit
git diff {fileName}
Thursday, May 4, 2017
Sunday, November 13, 2016
ClassLoader
ClassLoader:
Java class loader is a class which used to load classes at runtime.
ClassLoader in Java works on three principle:
- 1. Delegation principle: Responsibility of loading class is of parent classloader. A classloader will load class only if parent is not able to find or load class.
- 2. Visibility principle: Child class loader can see all the classes loaded by parent ClassLoader, but parent class loader can not see classes loaded by child.
- 3. Uniqueness principle: A class should be loaded exactly once. This is basically achieved by delegation and ensures that child ClassLoader doesn't reload the class already loaded by parent.
Types of Classloader:
There are three default class loader used in Java:
- 1. Bootstrap ClassLoader/Primordial ClassLoader is responsible for loading standard JDK class files from rt.jar and it is parent of all class loaders in Java. Bootstrap class loader don't have any parents, if you call String.class.getClassLoader() it will return null and any code based on that may throw NullPointerException in Java.
- 2. Extension ClassLoader delegates class loading request to its parent, Bootstrap and if unsuccessful, loads class form jre/lib/ext directory or any other directory pointed by java.ext.dirs system property. Extension ClassLoader in JVM is implemented by sun.misc.Launcher$ExtClassLoader.
- 3. Application class loader is responsible for loading application specific classes from CLASSPATH environment variable, -classpath or -cp command line option, Class-Path attribute of Manifest file inside JAR. Application class loader is a child of Extension ClassLoader and its implemented by sun.misc.Launcher$AppClassLoader class.
Except Bootstrap class loader, which is implemented in native language
mostly in C, all Java class loaders are implemented using
java.lang.ClassLoader.
Explicitly load a class:
Java provides API to explicitly load a class by
- 1. Class.forName(classname)
- 2. Class.forName(classname, initialized, classloader)
Uses:
- 1. J2EE uses multiple class loaders to load class from different location e.g. classes from WAR file will be loaded by Web-app ClassLoader while classes bundled in EJB-JAR is loaded by another class loader.
- 2. Some web server also supports hot deploy functionality which is implemented using ClassLoader.
- 3. You can also use ClassLoader to load classes from database or any other persistent store.
String.class.getClassLoader()
returns null because this class is loaded by bootstrap classLoader which is
not implemented in java , it's either implemented in c or c++ so there is no
reference for it that's why it returns null.
Why write a Custom ClassLoader in
Java
If you are expecting a class at the runtime or from FTP server or via
third party web service at the time of loading the class then you have to extend
the existing class loader.
How does Java ClassLoader Work
- 1. When JVM requests for a class, it invokes loadClass function of the ClassLoader by passing the fully classified name of the Class.
- 2. loadClass function calls for findLoadedClass() method to check that the class has been already loaded or not. It’s required to avoid loading the class multiple times.
- 3. If the Class is not already loaded then it will delegate the request to parent ClassLoader to load the class.
- 4. If the parent ClassLoader is not finding the Class then it will invoke findClass() method to look for the classes in the file system.
Custom ClassLoader in Java
By extending ClassLoader class and overriding loadClass(String name)
Saturday, August 27, 2016
Hibernate
Hibernate is a high-performance Object/Relational persistence and query
service which is licensed under the open source GNU Lesser General
Public License (LGPL) and is free to download. Hibernate not only takes
care of the mapping from Java classes to database tables (and from Java
data types to SQL data types), but also provides data query and
retrieval facilities.
It involves two files :-
Hibernate configuration file :-
It involves two files :-
- Hibernate configuration file (.cfg.xml)
- Hibernate mapping file (.hbm.xml)
Hibernate configuration file :-
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
com.mysql.jdbc.Driver
</property>
<!-- Assume test is the database name -->
<property name="hibernate.connection.url">
jdbc:mysql://localhost/test
</property>
<property name="hibernate.connection.username">
root
</property>
<property name="hibernate.connection.password">
root123
</property>
<!-- List of XML mapping files -->
<mapping resource="Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Properties :-
hibernate.dialect :-
Hibernate Mapping File :-
<!-- List of XML mapping files -->
<mapping resource="Employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Properties :-
hibernate.dialect :-
Hibernate Mapping File :-
Monday, June 6, 2016
Eclipse Issues
Issue:
"Java compiler level does not match the version of the installed Java project facet."
Resolution:
Go to project >> Properties >> Project Facets and change the facets to required java version
Issue:
Unbound classpath container: 'JRE System Library' in project 'XYZ'
Resolution:
Go to Project >> build path >> Configure Buildpath >> Libraries >> Add Library >> JRE System Library >> Select an existing library
Issue:
"Cannot change version of project facet Dynamic Web Module to 3.0"
Resolution:
Change the attributes of web-app tag in web.xml file of the project to point to module 3.0
Issue:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
Resolution:
Add the dependency for java servlet api to the classpath
"Java compiler level does not match the version of the installed Java project facet."
Resolution:
Go to project >> Properties >> Project Facets and change the facets to required java version
Issue:
Unbound classpath container: 'JRE System Library' in project 'XYZ'
Resolution:
Go to Project >> build path >> Configure Buildpath >> Libraries >> Add Library >> JRE System Library >> Select an existing library
Issue:
"Cannot change version of project facet Dynamic Web Module to 3.0"
Change the attributes of web-app tag in web.xml file of the project to point to module 3.0
Issue:
The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path
Add the dependency for java servlet api to the classpath
Issue:
How to enable to write mult-line string in eclipse
Resolution:
Go to Windows >> Preferences >> Java >> Editors >> Tying and Make sure that check box "Escape text when pasting into a string literal" is checked
How to enable to write mult-line string in eclipse
Resolution:
Go to Windows >> Preferences >> Java >> Editors >> Tying and Make sure that check box "Escape text when pasting into a string literal" is checked
Issue:
Warning message in an XML file "No grammar constraints (DTD or XML Schema) referenced in the document."
Resolution:
Just add <!DOCTYPE xml> below the tags <?xml version="1.0" encoding="UTF-8"?>
Warning message in an XML file "No grammar constraints (DTD or XML Schema) referenced in the document."
Resolution:
Just add <!DOCTYPE xml> below the tags <?xml version="1.0" encoding="UTF-8"?>
Issue:
While compiling maven project getting exception "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project {project name}: Compilation failure: Compilation failure"
Resolution:
Go to pom.xml and remove <scope>test</scope> all the dependencies.
While compiling maven project getting exception "Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project {project name}: Compilation failure: Compilation failure"
Resolution:
Go to pom.xml and remove <scope>test</scope> all the dependencies.
Issue:
Resolution:
Resolution:
Thursday, June 2, 2016
MAVEN
MAVEN is an innovative software project management tool that 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.
Steps to install MAVEN:-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PROJECT_NAME_IN_PACKAGE_NAME_STYLE</groupId>
<artifactId>NAME_OF_JAR</artifactId>
<version>VERSION_OF_JAR</version>
</project>
MVN Install:-
To create a java project in java
mvn archetype:generate
-DgroupId=com.anshul.ws
-DartifactId=MyWebService
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
To support eclipse
Like we have targets in case of Ant , we have phases in maven
Features of MAVEN:-
Steps to install MAVEN:-
- Download the binary file form apache's site
- Unzip the zip file and add to the environment variable.
- To confirm installation use mvn -version on command prompt.
- project
- src
- main
- java (the source code)
- resources
- test
- java (the unit test code )
- resources ()
- pom.xml (the configuration file containing the information to build the project)
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>PROJECT_NAME_IN_PACKAGE_NAME_STYLE</groupId>
<artifactId>NAME_OF_JAR</artifactId>
<version>VERSION_OF_JAR</version>
</project>
MVN Install:-
- It is used to install the package to local repository so that it can be referenced by several projects
- It is used to build the project
To create a java project in java
mvn archetype:generate
-DgroupId=com.anshul.ws
-DartifactId=MyWebService
-DarchetypeArtifactId=maven-archetype-quickstart
-DinteractiveMode=false
To support eclipse
mvn eclipse:eclipse -Dwtpversion=2.0
Like we have targets in case of Ant , we have phases in maven
Features of MAVEN:-
- Build process becomes very easy
To create a web-app using maven
- Using command prompt go to the directory where project needs to be created
- Type below
mvn archetype:generate -DgroupId=org.arsoft.projects.sood -DartifactId=arsood -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false - To be able to access the project on eclipse go to the directory and run command
mvn eclipse:eclipse -Dwtpversion=2.0
To create a Java project:
mvn archetype:generate -DgroupId=org.arsoft.projects.sood -DartifactId=arsood -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
To create an EJB project:
mvn archetype:generate -DgroupId=com.arsoft.projects -DartifactId=Common -DarchetypeArtifactId=ejb-javaee6 -DinteractiveMode=false
Understanding POM
- It stands for Project Object Model and is the fundamental unit of work in maven.
Saturday, January 4, 2014
WeCare
- All the tables would be under a database named WECARE.
- To register a hospital to WeCare, the hospital is provided some credentials by WeCare and these will be called WeCareRegisterationCredentials.
- These will be stored in table called LICENSE.
- This table will not be accessible to the hospitals
- The credentials will be able to register as many hospitals as purchased by the user in license agreement. The maximum number can be controlled by an external property
- Many members would be able to be registered under the hospital. The main types of the members would be
- Doctors
- Clinical Staff (Nurses,Pharmacists)
- Non Clinical Staff (Clerk, Drivers)\
Wednesday, December 25, 2013
Struts
1. Struts2 is configured in web.xml file using filter and filter-mapping tags as below
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,/resources/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2. The default location of struts.xml can be changed by giving the desired location in init-param of filter tag as given above.
3. Properties file can be accessed in struts2 using a constant in struts.xml as below:-
<constant name="struts.custom.i18n.resources" value="resources/ApplicationResources" />
4. Struts tags can be used in jsp files using taglib directives as below:-
<%@ taglib uri="/struts-tags" prefix="s" %>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,/resources/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2. The default location of struts.xml can be changed by giving the desired location in init-param of filter tag as given above.
3. Properties file can be accessed in struts2 using a constant in struts.xml as below:-
<constant name="struts.custom.i18n.resources" value="resources/ApplicationResources" />
4. Struts tags can be used in jsp files using taglib directives as below:-
<%@ taglib uri="/struts-tags" prefix="s" %>
Monday, December 16, 2013
Collections Framework
This framework has following features
- The framework had to be high-performance. The implementations for the fundamental collections (dynamic arrays, linked lists, trees, and hashtables) are highly efficient.
- The framework had allows different types of collections to work in a similar manner and with a high degree of interoperability.
- Extending and/or adapting a collection is very easy.
- Interfaces: These are abstract data types that represent
collections. Interfaces allow collections to be manipulated
independently of the details of their representation. In object-oriented
languages, interfaces generally form a hierarchy. These are the basic interfaces in this framework
- Collection Interface
- It is at the top of hierarchy.
- List Interface:-
- It extends collection interface
- Elements can be inserted or accessed by their position in the list, using a zero-based index.
- A list may contain duplicate elements.
- Implementations are ArrayList and LinkedList
- Set:-
- A Set is a Collection that cannot contain duplicate elements.
- Null can not be used.
- Implementations are HashSet
- SortedSet
- The SortedSet interface extends Set and declares the behavior of a set sorted in ascending order
- Null can not be used. \
- Implementations are TreeSet
- Map
- Given a key and a value, you can store the value in a Map object. After the value is stored, you can retrieve it by using its key
- Null can not be used.
- Implementations are HashMap
- MapEntry
- It enables you to work with a map entry that is the set of map keys
- SortedMap
- The SortedMap interface extends Map. It ensures that the entries are maintained in ascending key order
- Implementations are TreeMap.
- Enumeration
- It helps to deal with one element at a time for any collection
- It is almost obsolete and is replaced by iterator interface.
- Implementations, i.e., Classes: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.The main implementation classes of each of the collection interfaces are given above already in the interface definitions
- Algorithms: These are the methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the same method can be used on many different implementations of the appropriate collection interface.
- Synchronization - ArrayList is not thread-safe whereas Vector is thread-safe. In Vector class each method like add(), get(int i) is surrounded with a synchronized block and thus making Vector class thread-safe.
- Data growth -Internally, both the ArrayList and Vector hold onto their contents using an Array. When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.
- Collection.synchronizedList(List list)
- Collection.synchronizedCollection(Collection collection)
- Collection.synchronizedMap(Map map)
- HashMap is not synchronized whereas HashTable is.
- HaspMap permits null values in both key and value
- HaspMap is
- ArrayList :- resizable array and is indexed, non sysnchronized. It grows 50% of its size when more elements are added
- LinkedList :- double linked list and is indexed, get and set decreases performance while add and remove are fast and is non sysnchronized
- Vector : - It is synchronized and doubles its size when more elements are added. It also implements Queque interface so more methods like offer, peak, poll etc are available.
- HashSet: -Allows one null, order is not maintained.
- LinkedHashSet :- Order is maintained, one null allowed
- TreeSet :- Order is maintained, null is not allowed
- HashMap : It allows ONLY one null key and multiple null values. Ordered on the basis of keys. It is not synschronized
- TreeMap :- Null keys are not allowed at all but null values are.
- HashTable :- It is synchronized but unordered and null keys and null values are not allowed at all
Resource: http://www.docjar.com/html/api/java/util/
Collection Interface:
List Interface
Thursday, November 21, 2013
Web Services in JAVA
REST :- Stands for Representation State Transfer and is an architectural style of client-server application centered around the transfer of representations of resources through requests and responses.
The Web is comprised of resources. A resource is any item of interest. For example, the Boeing Aircraft Corp may define a 747 resource. Clients may access that resource with this URL:
A representation of the resource is returned (e.g., Boeing747.html). The representation places the client application in a state. The result of the client traversing a hyperlink in Boeing747.html is another resource is accessed. The new representation places the client application into yet another state. Thus, the client application changes (transfers) state with each resource representation --> Representational State Transfer! Here is Roy Fielding's explanation of the meaning of Representational State Transfer: "Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use."
In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs)
Note: URI (Uniform Resource Identifier) consists of either URL (Uniform Resource Locator )or URN(Uniform Resource Name) or both
REST is an Architectural Style, not a Standard
While REST is not a standard, it does use standards:
Note that "how" the web service generates the list is completely transparent to the client. All the client knows is that if he/she submits the above URL then a document containing the list of resources is returned. Since the implementation is transparent to clients, Parts Depot is free to modify the underlying implementation of this resource without impacting clients. This is loose coupling.
Principles of REST Web Service Design
1. The key to creating Web Services in a REST network (i.e., the Web) is to identify all of the conceptual entities that you wish to expose as services. Above we saw some examples of resources: parts list, detailed part data, purchase order. 2. Create a URL to each resource. The resources should be nouns, not verbs. For example, do not use this:
4. All resources accessible via HTTP GET should be side-effect free. That is, the resource should just return a representation of the resource. Invoking the resource should not result in modifying the resource.
5. No man/woman is an island. Likewise, no representation should be an island. In other words, put hyperlinks within resource representations to enable clients to drill down for more information, and/or to obtain related information.
6. Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more details.
7. Specify the format of response data using a schema (DTD, W3C Schema, RelaxNG, or Schematron). For those services that require a POST or PUT to it, also provide a schema to specify the format of the response.
8. Describe how your services are to be invoked using either a WSDL document, or simply an HTML document.
Reference:-
http://www.xfront.com/REST-Web-Services.html
http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/
The Web is comprised of resources. A resource is any item of interest. For example, the Boeing Aircraft Corp may define a 747 resource. Clients may access that resource with this URL:
A representation of the resource is returned (e.g., Boeing747.html). The representation places the client application in a state. The result of the client traversing a hyperlink in Boeing747.html is another resource is accessed. The new representation places the client application into yet another state. Thus, the client application changes (transfers) state with each resource representation --> Representational State Transfer! Here is Roy Fielding's explanation of the meaning of Representational State Transfer: "Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use."
In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs)
Note: URI (Uniform Resource Identifier) consists of either URL (Uniform Resource Locator )or URN(Uniform Resource Name) or both
REST is an Architectural Style, not a Standard
While REST is not a standard, it does use standards:
- HTTP
- URL
- XML/HTML/GIF/JPEG/etc (Resource Representations)
- text/xml, text/html, image/gif, image/jpeg, etc (MIME Types)
Note that "how" the web service generates the list is completely transparent to the client. All the client knows is that if he/she submits the above URL then a document containing the list of resources is returned. Since the implementation is transparent to clients, Parts Depot is free to modify the underlying implementation of this resource without impacting clients. This is loose coupling.
Principles of REST Web Service Design
1. The key to creating Web Services in a REST network (i.e., the Web) is to identify all of the conceptual entities that you wish to expose as services. Above we saw some examples of resources: parts list, detailed part data, purchase order. 2. Create a URL to each resource. The resources should be nouns, not verbs. For example, do not use this:
Note the verb, getPart. Instead, use a noun:3. Categorize your resources according to whether clients can just receive a representation of the resource, or whether clients can modify (add to) the resource. For the former, make those resources accessible using an HTTP GET. For the later, make those resources accessible using HTTP POST, PUT, and/or DELETE.
4. All resources accessible via HTTP GET should be side-effect free. That is, the resource should just return a representation of the resource. Invoking the resource should not result in modifying the resource.
5. No man/woman is an island. Likewise, no representation should be an island. In other words, put hyperlinks within resource representations to enable clients to drill down for more information, and/or to obtain related information.
6. Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more details.
7. Specify the format of response data using a schema (DTD, W3C Schema, RelaxNG, or Schematron). For those services that require a POST or PUT to it, also provide a schema to specify the format of the response.
8. Describe how your services are to be invoked using either a WSDL document, or simply an HTML document.
Reference:-
http://www.xfront.com/REST-Web-Services.html
http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/
Web.xml
References:-
http://download.oracle.com/docs/cd/E13222_01/wls/docs81/webapp/web_xml.html
This file is used to define each servlet and JSP page inside
a web-application.
It is found in WEB-INF directory under the document root of
the web application.
It is also called Deployment Descriptor
Context parameters are accessible to any servlet or JSP in
the web-app and can be accessed through ServletContext object.
String value =
getServletContext().getInitParameter("name_of_context_initialization_parameter");
For springs Context param name for
application
context is
"contextConfigLocation" with value "*.xml"
log4j is
"log4jConfigLocation" with value "*.properties"
applicationContext.xml is an XML file having the context parameters
Init parameters are specific to a particular servlet and and
can be accessed through ServletConfig object.
String value =
getServletConfig().getInitParameter("name_of_context_initialization_parameter");
load-on-startup gives the order in which the servlet will
initialize
<?xml version="1.0"
encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>The name of the application </display-name>
<description>Description of Application</description>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<description>Description of parameter</description>
<param-name>name_of_context_initialization_parameter</param-name>
<param-value>value_of_context_initializtion_parameter</param-value>
</context-param>
//In case of Servlets
, we define our own Servlet classes and corresponding mappings are given in
web.xml
<servlet>
<servlet-name>guess_what_name_of_servlet</servlet-name>
<description>Again, some description</description>
<servlet-class>com.foo-bar.somepackage.TheServlet</servlet-class>
<init-param>
<param-name>foo</param-name>
<param-value>bar</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>name_of_a_servlet</servlet-name>
<url-pattern>*.some_pattern</url-pattern>
</servlet-mapping>
//In case of struts 2
, we define the filters and corresponding mapping of FilterDispatcher in
web.xml
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
//In case of springs, we define the servlet and corresponding mapping of Dispatcher Serv
<servlet>
<servlet-name>employee</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>employee</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/employee-servlet.xml</param-value>
</context-param>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
</web-app>
Wednesday, November 20, 2013
SQL
Primary Key:-
Unique Key:-
- A column or a group of columns in a table which uniquely identifies a row.
- It can not accept null value
- It is created as
CONSTRAINT pk_name PRIMARY KEY (column1, column2, ...) - A table can have only one primary key column(s)
- It created a clustered index by default
- It can be referred as a foreign key in some other table
Unique Key:-
- A column or a group of columns in a table which uniquely identifies a row.
- It can accept null value
- It is created as
CONSTRAINT uk_name UNIQUE (column1, column2, ...) - A table can have more than one unique key column(s)
- It creates a non clustered index by default
- It can not be referred as a foreign key in other table
Subscribe to:
Posts (Atom)
SpringBoot Application Event Listeners
When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...
-
1. Create a tld file inside WEB-INF folder having declaration of the custom function as below <?xml version="1.0" encoding=...
-
Issue: "Java compiler level does not match the version of the installed Java project facet." Resolution: Go to project >...