How can I create a copy of an Oracle table without copying the data
create table xyz_new as select * from xyz where 1=0;
Static : can not accept parameters
dynamic : can accept parameters.
Static include are faster than dynamic includes
in static include the content of the file will be included at translation phase.
like copy and paste,
in dynamic include the response of the included file be included to the original
response at run time.
By default, servlet is multithreaded unless you specify it through
SingleThreadModel implemention or use isThreadSafe attribute for JSP (knowing that
JSPs are turned into servlets).
struts_2 -> [Link] --> name can't be changed
struts_1 -> [Link] --> name can be changed
String str = null;
if([Link]("Test")) {
/* The code here will not be reached, as an exception will be thrown. */
}
String str = null;
if("Test".equals(str)) {
/* Correct use case. No exception will be thrown. */
}
If you have to print the string representation of any object, the don�t use
[Link](). This is a very soft target for NPE. Instead use
[Link](object).
Even if object is null in valueOf, it will not give exception and will prints
�null� to output stream
catching NullPointerException adds significantly more performance overhead
Struts spec Interceptors
Servlet spec Filters
Servlet is a special type of java class. it has init() method which works like a
constructor and understood by the servlet container.
When we pass Key and Value object to put() method on Java HashMap, HashMap
implementation calls hashCode method on Key object and applies returned hashcode
into its own hashing function to find a bucket location for storing Entry object,
important point to mention is that HashMap in Java stores both key and value object
as [Link] in bucket which is essential to understand the retrieving logic. If
people fails to recognize this and say it only stores Value in the bucket they will
fail to explain the retrieving logic of any object stored in Java HashMap
while using servlets ,we never instantiate the servlet rather the container does it
for us by using the newInstance() defined in the Class class; which in turn uses
the empty(Default) constructor to create a new instance of the servlet
if you don't override hashcode(), and use object as key, then it can't be retrieved
prevents duplication in hashset
[Link] vs [Link]
if you want to maintain state, use singleton; if you want a class with static
methods use static
Singleton object stores in Heap but, static object stores in stack
we can implement interface with Singleton class but not with Static class
We can clone the object of Singleton but, we can not clone the static class object
Singleton class follow the OOP(object oriented principles) but not static class
the detached criteria allows you to create the query without Session
Criteria criteria =
[Link]().createCriteria([Link]);
DetachedCriteria criteria = [Link]([Link]);
Hibernate object life cycle
new Employee() transient
[Link]() persistent
[Link]() detached
If we do any modifications all the changes will first applied to the object in
session cache only (Let__ we do the modifications 5 times, then 5 times we need to
save the changes into the database right, which means number of round trips from
our application to database will be increased, Actually if we load an object from
the database, first it will saves in the cache-memory so if we do any number of
changes all will be effected at cache level only and finally we can call save or
update method so with the single call of save or update method the data will be
saved into the database
[Link]("Refresh", 10); //instruct the browser to request for an
updated page in 10 seconds from the server
[Link]("Cache-Control","no-cache"); //instruct the browser not to
cache the page
request parameters -- mainly form data is sent as parameters
request attributes -- add / modify attributes from the request from client
getSession(true) -- If a session does not already exist then it creates a new
session for the user
getSession(false) -- If a session does not already exist then it returns null
//to add a cookie
Cookie myCookie = new Cookie("aName", "aValue");
[Link](myCookie);
//to delete a cookie
[Link]("aName", null);
[Link](0);
[Link]("/");
[Link](myCookie);
class A {
Integer display() {
return 10;
}
}
class B extends A {
int display() {
return 10;
}
}
will not be allowed should be Integer in class B also
volatile: communicate content of memory between threads
public abstract class is allowed
public class abstract is not allowed
The trigger is said to be defined on the table, view, schema, or database
modifies table data and enforces security
TreeSet is implemented using a tree structure(red-black tree in algorithm book)
tree set sorts based on comparable
Filters vs Servlets
Filter is used for filtering the request and perform some action like authenticity
of session, user is valid or not for that request, etc. Filter doesnot generate any
new content
Servlet is used for performing the action which needs to be taken for particular
request like user login, get the response based on user role, interacts with
database for getting the data, business logic execution, etc. Servlets generate the
content
Thread Pools are useful when you need to limit the number of threads running in
your application at the same time
The idea is to have the threads always existing, so that we won't have to pay
overhead time for creating them every time
Scanner is designed for cases where you need to parse a string, pulling out data of
different [Link] you're parsing text data from a source outside your program,
like from a file, or from the user, that's where a Scanner comes in handy
One big difference is that a Scanner can operate on input streams, so you do not
need to have it in memory all at once
The CodePro JUnit Test Case Generation facility allows you to automate the creation
of comprehensive JUnit regression test cases. Given an input class, the tool
creates a corresponding test class complete with multiple test methods for each
input class method.
or you can use junit doclet
JBOSS 5 different server configurations:
minimal, default, all, standard and web
minimal: This is just the bare server. There is no web container, no EJB or JMS
support
default: It has the most frequently used services required to deploy a Java EE
application
all: starts all the available services. This includes the RMI/IIOP and
clustering services
get the user-agent string for the mobile device
How HTTPS Works [uses public key encryption]
Computers agree on how to encrypt [client sends hello with key-cipher-hash;
server replies back with same parameters]
server sends certificate [server sends certificate which contains the public
key]
your computer says start encrypting [client n server calculates master secret
code;]
The server says start encrypting []
All messages are now encrypted [username, password are encrypted now]
Asymmetric: Encrypt using one key & decrypt using different key
View vs Materialized View
Materialized view stores data in disk; while view does not
In case of View we always get latest data; Materialized view we need to refresh the
view for getting latest data
View is used when we a particular set of data to be stored (could be set of rows or
set of coloumns)from the table
Nested
/\
/ \
Static Non-Static / Inner