Saturday, 18 May 2013
Interfaces and Classes in Servlet
Interfaces in javax.servlet package:
- Servlet
- ServletRequest
- ServletResponse
- RequestDispatcher
- ServletConfig
- ServletContext
- SingleThreadModel
- Filter
- FilterConfig
- FilterChain
- ServletRequestListener
- ServletRequestAttributeListener
- ServletContextLitstener
- ServletContextAttributeListener
- GenericServlet
- ServetInputStream
- ServletOutputStream
- ServletRequestWrapper
- ServletResponseWrapper
- ServletRequestEvent
- ServletContextEvent
- ServletRequestAttributeEvent
- ServletContextAttributeEvent
- ServletException
- UnavailableException
- HttpServletRequest
- HttpServletResponse
- HttpSession
- HttpSessionListener
- HttpSessionAttributeListener
- HttpSessionBindingListener
- HttpSessionActivationListener
- HttpSessionContext (deprecated now)
- HttpServlet
- Cookie
- HttpServletRequestWrapper
- HttpServletResponseWrapper
- HttpSessionEvent
- HttpSessionBindingEvent
- HttpUtils (depricated now)
History of Java
James Gosling, Mike Sheridan, and Patrick Naughton initiated the java language project in June 1991.
Originally designed for small. embedded systems in electronic appliances like set-top boxes. Initially called Oak was renamed as "Java". Java is just a name not an acronym.
Originally developed by james Gosling at SUN Microsystems( which is now a subsidiary of oracle Corporation) and released in 1995. JDK 1.0 released in (January 23,1996).
Originally designed for small. embedded systems in electronic appliances like set-top boxes. Initially called Oak was renamed as "Java". Java is just a name not an acronym.
Originally developed by james Gosling at SUN Microsystems( which is now a subsidiary of oracle Corporation) and released in 1995. JDK 1.0 released in (January 23,1996).
Servlet Interface
Servlet Interface provides common behavior to all the servlet Servlet interface needs to be implemented for creating any servlet (either directly or indirectly). It provides 3 life cycle methods that are used to initialize the servlet, to service the requests and to destroy the servlet and 2 non-life cycle methods.
Methods of servlet Interface: There are 5 methods in servlet interface. The init, service and destroy are the life cycle method these are invoked by the web container.
Methods of servlet Interface: There are 5 methods in servlet interface. The init, service and destroy are the life cycle method these are invoked by the web container.
- public void init(ServletConfig config) initializes the servlet. It is the life cycle method invoked by the web container only once.
- public void service(ServletRequest request, ServletResponse response) provides response for the incoming request. It is invoked at each request by the web container.
- public void destroy() is invoked only once and indicates that servlet is being destroyed.
- public ServletCofig getServletConfig() returns the object of ServletCofig.
- public String getServletInfo() returns information about servlet such as writer, copyright,version etc.
import java.io.*;
import javax.servlet.*;
public class First implements Servlet{
ServletConfig config=null;
public void init(ServletConfig config){
this.config=config;
System.out.println("servlet is initialized");
}
public void service(ServletRequest req, ServletResponse res)throws IOException, ServletException{
res.setContentType("text/html");
PrintWriter out=res.getWriter();
out.print("<html>");<body>");
out.print("<b>Hai</b>");
out.print("</html></body>");
}
public void destroy(){
System.out.println("Servlet is destroyed");
}
pulbic ServletCofig getServletConfig(){
return config;
}
public String getServletInfo(){
return "copyrith @ futureimpact"
}
Thursday, 16 May 2013
HTML 5 TAGS Browser support
HTML 5:
The below tags which are comes with HTML5 and which are supported in All Major browsers and not supported with.
The below tags which are comes with HTML5 and which are supported in All Major browsers and not supported with.
Tags/Attributes | Browser support |
---|---|
contenteditable | All Browsers |
contextmenu | present not supported any browser |
accessKey | Not supported by Opera |
draggable | IE8 and earlier versions, safari 5.1.2 Not supported |
Contenteditable in HTML
Contenteditable : It is new in HTML 5. This Attribute is supported in all major browsers. The contenteditable attribute specifies whether the content of an element is editable or not.
Syntax: < element contenteditable="true|false|inherit">
The attribute values of this contenteditable are true, false, inherit ( inherit specifies that the element is editable if its parent is)
Syntax: < element contenteditable="true|false|inherit">
The attribute values of this contenteditable are true, false, inherit ( inherit specifies that the element is editable if its parent is)
Access Key in HTML
Access Key: To specify a shortcut key to access/focus a specific element in your HTML page use <accessKey>
This accessKey attribute works in all major browsers except Opera.
In HTML 5 the accessKey attribute can be used to any HTML element (it will validate on any HTML element.).
In HTML 4 the accessKey attribute can be used with <a> , <area> , <button> , <input> <label> , <legend> , <textarea>
The syntax: <element accessKey="character">
This accessKey attribute works in all major browsers except Opera.
In HTML 5 the accessKey attribute can be used to any HTML element (it will validate on any HTML element.).
In HTML 4 the accessKey attribute can be used with <a> , <area> , <button> , <input> <label> , <legend> , <textarea>
The syntax: <element accessKey="character">
Thursday, 9 May 2013
Cascading Order
Multiple Styles Will Cascade into One
Styles can be specified:
Styles can be specified:
- inside an HTML element
- inside the head section of an HTML page
- in an external CSS file
Cascading order:
What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number 4 has the highest priority:
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number 4 has the highest priority:
- Browser default
- External style sheet
- Internal style sheet (in the head section)
- Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the tag, or in an external style sheet, or in a browser (a default value).
Design Patterns Intro
The Design Pattern is not a framework and is not directly deployed via code.
Design Pattern have two main usages:
Design pattern are based on the base principles of object orientated design.Design Pattern have two main usages:
- Common language for developers: they provide developer a common langauage for certain problems. for example if a developer tells another developer that he is using a singleton, the another developer (Should) know exactly what is singleton.
- Capture best practices: Design patterns capture solutions which have been applied to certain problems. By learning these patterns and the problem they are trying to solve a un experienced developer can learn a lot about software design.
- Program to an interface not an implementation
- Favor object composition over inheritance
- Creational Patterns
- Structural Patterns
- Behavioral Patterns
Creational Patterns:
- Factory Pattern
- Abstract Factory Pattern
- Singleton Pattern
- Builder Pattern
- Prototype Pattern
- Adapter Pattern
- Bridge pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern
- Flyweight Pattern
- Proxy Pattern
- Chain of responsibility Pattern
- Command Pattern
- Interpreter Pattern
- Iterator Pattern
- Mediator Pattern
- Momento Pattern
- Observer Pattern
- State Pattern
- Template Pattern
- Visitor Pattern
Factory Pattern
Factory of what? of classes. In simple words, if we have super class and n subclasses, and based on data provided, we have to return the object of one of the sub-classes, we use a factory pattern.
Let's take an example to understand this pattern.
Example: Let's suppose an application asks for entering the name and sex of a person. If the sex is male(M), it displays welcome message saying Hello Mr. and if the sex is Female (F), it displays message saying hello Ms.
The skeleton of the code can be given here.
public class Person{
//name string
public String name;
private String gender;
public String getName() {
return name;
}
public String getGender(){
return gender;
}
}
This is a simple class person having methods for name and gender. Now we will have two sub-classes, Male and Female which will print the welcome message on screen.
public class Male extends Person{
public Male(String fullName){
System.out.println("Hello Mr."+fullName);
}
}
Also the class Female
public class Female extends Person{
public Female(String fullName){
System.out.println("Hello Ms. "+fullName);
}
}
Now, we have to create a client, or a salutationFactory which will return the welcome messgae depending on the data provided.
public class SalutationFactory{
public static void main(String args[]){
SalutationFactory factory=new SalutationFactory();
factory.getPerson(args[0],args[1]);
}
public Person getPerson(String name, String gender){
if(gender.equals("M"))
return new Male(name);
else if(gender.equals("F"))
return new Female(name);
else
return null;
}
}
This class accepts two arguments from the system at runtime and prints the names.
Running the program:
After compiling and running the code on my computer with the arguments Srinivas and M:
java Srinivas M
the result returned is : "Hello Mr. Srinivas".
when to use a Factory Pattern?
the factory patterns can be used in following cases:
Let's take an example to understand this pattern.
Example: Let's suppose an application asks for entering the name and sex of a person. If the sex is male(M), it displays welcome message saying Hello Mr.
The skeleton of the code can be given here.
public class Person{
//name string
public String name;
private String gender;
public String getName() {
return name;
}
public String getGender(){
return gender;
}
}
This is a simple class person having methods for name and gender. Now we will have two sub-classes, Male and Female which will print the welcome message on screen.
public class Male extends Person{
public Male(String fullName){
System.out.println("Hello Mr."+fullName);
}
}
Also the class Female
public class Female extends Person{
public Female(String fullName){
System.out.println("Hello Ms. "+fullName);
}
}
Now, we have to create a client, or a salutationFactory which will return the welcome messgae depending on the data provided.
public class SalutationFactory{
public static void main(String args[]){
SalutationFactory factory=new SalutationFactory();
factory.getPerson(args[0],args[1]);
}
public Person getPerson(String name, String gender){
if(gender.equals("M"))
return new Male(name);
else if(gender.equals("F"))
return new Female(name);
else
return null;
}
}
This class accepts two arguments from the system at runtime and prints the names.
Running the program:
After compiling and running the code on my computer with the arguments Srinivas and M:
java Srinivas M
the result returned is : "Hello Mr. Srinivas".
when to use a Factory Pattern?
the factory patterns can be used in following cases:
- when a class does not know which class of objects it must create.
- a class specifies its sub-classes to specify which objects to create.
- In programmers language( very raw form), you can use factory pattern where you have to create an object of any one of sub-classes depending on the data provided.
Thursday, 2 May 2013
Error: Your content must have a ListView whose id attribute is android.R.id.list
When you are creating A ListVIew Item in
Android and want to display your selected item on Toast message. When you are
running that app and if you get an error like below.
"Your content must have a ListView whose
id attribute is android.R.id.list"
For the above problem answer is.
If your are using ListActivity then you must have ListView in your
xml of layout and must be id of
ListView is
android.R.id.list
So must add listview in your layout like below code
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/android:list"
/>
In The Java Code it’l
be get like this.
lv = (ListView)
findViewById(android.R.id.list);
Monday, 22 April 2013
The $() factory function: in JQuery
All type of selectors available in jQuery, always start with the dollar sign and parentheses: $().
The factory function $() makes use of following three building blocks while selecting elements in a given document:
jQuery | Description |
---|---|
Tag Name: | Represents a tag name available in the DOM. For example $('p')selects all paragraphs in the document. |
Tag ID: | Represents a tag available with the given ID in the DOM. For example$('#some-id') selects the single element in the document that has an ID of some-id. |
Tag Class: | Represents a tag available with the given class in the DOM. For example $('.some-class') selects all elements in the document that have a class of some-class. |
All the above items can be used either on their own or in combination with other selectors. All the jQuery selectors are based on the same principle except some tweaking.
NOTE: The factory function $() is a synonym of jQuery() function. So in case you are using any other JavaScript library where $ sign is conflicting with some thing else then you can replace $sign by jQuery name and you can use function jQuery() instead of $().
The Document Ready Event in JQuery
You might have noticed that all jQuery methods in our examples, are inside a document ready event:
$(document).ready(function(){
// jQuery methods go here...
});
This is to prevent any jQuery code from running before the document is finished loading (is ready).
It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet
Tip: The jQuery team has also created an even shorter method for the document ready event:
// jQuery methods go here...
});
This is to prevent any jQuery code from running before the document is finished loading (is ready).
It is good practice to wait for the document to be fully loaded and ready before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section.
Here are some examples of actions that can fail if methods are run before the document is fully loaded:
Trying to hide an element that is not created yet
Trying to get the size of an image that is not loaded yet
Tip: The jQuery team has also created an even shorter method for the document ready event:
$(function(){
// jQuery methods go here...
});
Use the syntax you prefer. We think that the document ready event is easier to understand when reading the code.
// jQuery methods go here...
});
Use the syntax you prefer. We think that the document ready event is easier to understand when reading the code.
How to use JQuery library
Here we can see that how to use JQuery in our HTML Page. If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network). Both Google and Microsoft host jQuery. To use jQuery from Google or Microsoft, use one of the following in alternate downloading:
JQuery Introduction
jQuery is a fast and concise JavaScript Library created by John Resig in 2006 with a nice motto:Write less, do more.
jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core features supported by jQuery:
jQuery simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
jQuery is a JavaScript toolkit designed to simplify various tasks by writing less code. Here is the list of important core features supported by jQuery:
- DOM manipulation: The jQuery made it easy to select DOM elements, traverse them and modifying their content by using cross-browser open source selector engine calledSizzle.
- Event handling: The jQuery offers an elegant way to capture a wide variety of events, such as a user clicking on a link, without the need to clutter the HTML code itself with event handlers.
- AJAX Support: The jQuery helps you a lot to develop a responsive and feature-rich site using AJAX technology.
- Animations: The jQuery comes with plenty of built-in animation effects which you can use in your websites.
- Lightweight: The jQuery is very lightweight library - about 19KB in size ( Minified and gzipped ).
- Cross Browser Support: The jQuery has cross-browser support, and works well in IE 6.0+, FF 2.0+, Safari 3.0+, Chrome and Opera 9.0+
- Latest Technology: The jQuery supports CSS3 selectors and basic XPath syntax.
How to install jQuery ?
This is very simple to do require setup to use jQuery library. You have to carry two simple steps:
Go to the download page to grab the latest version available. Now put downloaded jquery-1.3.2.min.js file in a directory of your website, e.g. /jquery. The downloaded file name jquery-1.3.2.min.js may vary for your version. Your minified version would be kind of unreadable which would not have any new line or unnecessary words in it. The jQuery does not require any special installation and very similar to JavaScript, we do not need any compilation or build phase to use jQuery.
This is very simple to do require setup to use jQuery library. You have to carry two simple steps:
Go to the download page to grab the latest version available. Now put downloaded jquery-1.3.2.min.js file in a directory of your website, e.g. /jquery. The downloaded file name jquery-1.3.2.min.js may vary for your version. Your minified version would be kind of unreadable which would not have any new line or unnecessary words in it. The jQuery does not require any special installation and very similar to JavaScript, we do not need any compilation or build phase to use jQuery.
Saturday, 20 April 2013
Friday, 19 April 2013
programm to reading values from keyboard into an arraylist untill 'z' keyword enterd, stops reading and than sorting them in ascending order.
import java.io.*;
import java.util.*;
public class ArraysOne {
public static void main(java.lang.String[] args)
{
//int i;
ArrayList al=new ArrayList();
try{
Scanner input = new Scanner(System.in);
int check=0;
while(true){
check = input.nextInt();
if(check == 'z' || check=='Z') break;
al.add(check);
}
} catch(Exception e){
e.printStackTrace();}
Iterator itr=al.iterator();
while(itr.hasNext()){
Object i=itr.next();
System.out.println(i);
}
int j=al.size();
System.out.println("Size"+j);
Collections.sort(al);
System.out.println("ArrayList is sorted");
for(Integer temp: al){
System.out.println(temp);
}
/*for(int i=j;i>=i-1;i--){
for(int k=i-1;k>=;k--){
if(al.get(i)al.get(k)){
System.out.println(al.get(k)); }
else{ System.out.println(al.get(i)); }
}
}*/
}
}
import java.util.*;
public class ArraysOne {
public static void main(java.lang.String[] args)
{
//int i;
ArrayList
try{
Scanner input = new Scanner(System.in);
int check=0;
while(true){
check = input.nextInt();
if(check == 'z' || check=='Z') break;
al.add(check);
}
} catch(Exception e){
e.printStackTrace();}
Iterator itr=al.iterator();
while(itr.hasNext()){
Object i=itr.next();
System.out.println(i);
}
int j=al.size();
System.out.println("Size"+j);
Collections.sort(al);
System.out.println("ArrayList is sorted");
for(Integer temp: al){
System.out.println(temp);
}
/*for(int i=j;i>=i-1;i--){
for(int k=i-1;k>=;k--){
if(al.get(i)al.get(k)){
System.out.println(al.get(k));
else{ System.out.println(al.get(i));
}
}*/
}
}
Adding two Arrays and finding the third array is positive or negative???
import java.util.*;
import java.lang.*;
import java.io.*;
class AddArrays1
{
public static void main(String[] args)
{
//Scanner sc=new Scanner(System.in);
int a[]={1,2,3};
int b[]={2,3,-4};
int c[]=new int[3];
for(int i=0;i{
c[i]=a[i]+b[i];
System.out.println(c[i]);
}
for (int i=0; i{
if (c[i] > 0) {
System.out.println(c[i]+ " is positive");
} else {
System.out.println(c[i] + " is not positive");
}
}
}
}
import java.lang.*;
import java.io.*;
class AddArrays1
{
public static void main(String[] args)
{
//Scanner sc=new Scanner(System.in);
int a[]={1,2,3};
int b[]={2,3,-4};
int c[]=new int[3];
for(int i=0;i{
c[i]=a[i]+b[i];
System.out.println(c[i]);
}
for (int i=0; i
if (c[i] > 0) {
System.out.println(c[i]+ " is positive");
} else {
System.out.println(c[i] + " is not positive");
}
}
}
}
Sunday, 14 April 2013
How To Troubleshoot Your System For Memory Problems In Windows 7
Windows 7 includes built-in features to help you identify and diagnose problems with memory.
If you suspect a computer has a memory problem that isn’t being automatically detected, you can run the Windows Memory Diagnostics utility by completing the following steps:
Step 1: - Click Start, type mdsched.exe in the Search box, and then press Enter
Step 2: - Choose whether to restart the computer and run the tool immediately or schedule the tool to run at the next restart.
Windows Memory Diagnostics runs automatically after the computer restarts and performs a standard memory test automatically. If you want to perform fewer or more tests, press F1, use the Up and Down arrow keys to set the Test Mix as Basic, Standard, or Extended, and then press F10 to apply the desired settings and resume testing.
When testing is completed, the computer restarts automatically. You’ll see the test results when you log on.
Note that if a computer crashes because of failing memory, and Windows Memory Diagnostics detects this, the system will prompt you to schedule a memory test the next time the computer is restarted.
Saturday, 16 March 2013
Enumeration in Java
Java.util.Enumeration:
Enumeration is one of the predefined Interface present in Java.util.* package. An object of
Enumeration Interface object is used for extracting or retrieving data from any
legacy collection framework variable only in forward direction. When we create
on enumeration, which is by default pointing just before the first element at
any legacy collection frameworks.
The functionality of Enumeration (Synchronized) is more or
less Iterator Interface (Non-Synchronized)
Methods:
Public boolean hasMoreElements(): it
returns true provided enumeration Interface object is having more number of
elements in legacy collection framework
variable otherwise it returns false.
Public object nextElement
(): is used for uptaining next
element of any legacy collection framework variable provided Public boolean hasMoreElements() must
returns true.
Syntax:
While(en.hasMoreElements()){
Object obj=en.nextElement();
System.out.println(obj);
}
Friday, 15 March 2013
One of Logical Interview Question I faced:
A good Employee is defined who has all the following properties:
1. Employee must be married.
2. Employee has at least 2 children
3. His Middle Name Start with “K” and Ends With “E”.
4. His Last Name has at least 4 characters, and starts with “A”
5. In His childrens have at least one name “Raja”.
Write a method:
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
Answer:
import java.io.*;
class Employ
{
boolean isMarried;
int noOfChild;
String middleName;
String lastName;
String[] childNames;
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
this.isMarried=isMarried;
this.noOfChild=noOfChild;
this.middleName=middleName;
this.lastName=lastName;
this.childNames=childNames;
int mlength=middleName.length();
int ml=mlength-1;
int lnLength=lastName.length();
int count=0,name=0;
int childln=childNames.length;
if(isMarried==true)
{
//return true;
}else {
System.out.println("He is not Married");
}
if (noOfChild<=2){
//return true;
}else {
System.out.println("not about children");
}
//System.out.println(ml);
// System.out.println(middleName.c harAt(ml));
// System.out.println(middleName.c harAt(0));
if(middleName.charAt(0)=='k') {
if(middleName.charAt(ml)!='e') {
// return true;
}else{
System.out.println("Name not in COrrect formate");
}
}
if(lnLength>4){
for(int i=0;iif(lastName.charAt(i)=='a')
count=count+1;
}
//System.out.println(count);
if(count>=2){
}else{
System.out.println("Last Name not in Correct form");
}
}
// System.out.println(childNames[0 ]);
//System.out.println(childln);
for(int i=0;i{
if(childNames[i].equals("Raja" )){
name=name+1;
}
if(name>=1){
//return true;
}else{
System.out.println("NO One Children is RAJA");
}
}
System.out.println(" Good Employee");
return true;
}
public static void main(String[] args)
{
String mName="kiranew";
String lName="Maadhu";
boolean married=true;
String[] childN={"Raja","Latha"};
int noChild=2;
Employ em=new Employ();
em.isGoodEmployee(married,noCh ild,mName,lName,childN);
}
}
1. Employee must be married.
2. Employee has at least 2 children
3. His Middle Name Start with “K” and Ends With “E”.
4. His Last Name has at least 4 characters, and starts with “A”
5. In His childrens have at least one name “Raja”.
Write a method:
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
Answer:
import java.io.*;
class Employ
{
boolean isMarried;
int noOfChild;
String middleName;
String lastName;
String[] childNames;
boolean isGoodEmployee( boolean isMarried, int noOfChild , String middleName , String lastName , String[] childNames){
this.isMarried=isMarried;
this.noOfChild=noOfChild;
this.middleName=middleName;
this.lastName=lastName;
this.childNames=childNames;
int mlength=middleName.length();
int ml=mlength-1;
int lnLength=lastName.length();
int count=0,name=0;
int childln=childNames.length;
if(isMarried==true)
{
//return true;
}else {
System.out.println("He is not Married");
}
if (noOfChild<=2){
//return true;
}else {
System.out.println("not about children");
}
//System.out.println(ml);
//
//
if(middleName.charAt(0)=='k') {
if(middleName.charAt(ml)!='e')
// return true;
}else{
System.out.println("Name not in COrrect formate");
}
}
if(lnLength>4){
for(int i=0;i
count=count+1;
}
//System.out.println(count);
if(count>=2){
}else{
System.out.println("Last Name not in Correct form");
}
}
//
//System.out.println(childln);
for(int i=0;i
if(childNames[i].equals("Raja"
name=name+1;
}
if(name>=1){
//return true;
}else{
System.out.println("NO One Children is RAJA");
}
}
System.out.println(" Good Employee");
return true;
}
public static void main(String[] args)
{
String mName="kiranew";
String lName="Maadhu";
boolean married=true;
String[] childN={"Raja","Latha"};
int noChild=2;
Employ em=new Employ();
em.isGoodEmployee(married,noCh
}
}
Thursday, 14 March 2013
Add “Recycle Bin” to My Computer in Windows 7 and Vista:
Would you like to add the “Recycle Bin” icon to My Computer so that you need not go back to the desktop to access it when required? Well, here is how you can do that:
Open the Registry Editor and navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace
Right-click on “NameSpace” and select New -> Key. Name the key with the following name:
{645FF040-5081-101B-9F08-00AA002F954E}
Now, open “My Computer” and hit F5 to refresh the screen. This should show up the “Recycle Bin” icon.
Open the Registry Editor and navigate to the following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace
Right-click on “NameSpace” and select New -> Key. Name the key with the following name:
{645FF040-5081-101B-9F08-00AA002F954E}
Now, open “My Computer” and hit F5 to refresh the screen. This should show up the “Recycle Bin” icon.
Add Programs to Windows Startup:
You can now add your favorite programs to Windows Startup without the need for using the start-up folder. Here is a way to do this:
Open the Registry Editor and navigate to the following key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run On the right-side
pane, create a new “String Value” and rename it to the name of the program that you want to
add (you can give any name, it doesn’t matter). Double-click on the “String Value”, in the “Value
data” field add the path of the executable program that has to execute at startup. Reboot the computer to see the changes in effect.
Open the Registry Editor and navigate to the following key:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run On the right-side
pane, create a new “String Value” and rename it to the name of the program that you want to
add (you can give any name, it doesn’t matter). Double-click on the “String Value”, in the “Value
data” field add the path of the executable program that has to execute at startup. Reboot the computer to see the changes in effect.
Friday, 1 March 2013
Spped Up Your Internet
speed up your internet connection using firefox
1. Type “about:config” into the address bar and hit return. Scroll
down and look for the following entries:
network.http.pipelining
network.http.proxy.pipelining
network.http.pipelining.maxreq uests
Normally the browser will make one request to a web page at a time.
When you enable pipelining it will make several at once, which really
speeds up page loading.
2. Alter the entries as follows:
Set “network.http.pipelining” to “true”
Set “network.http.proxy.pipelining ” to “true”
Set “network.http.pipelining.maxre quests” to some number like 30. This
means it will make 30 requests at once.
3. Lastly right-click anywhere and select New-> Integer.
Name it “nglayout.initialpaint.delay” and set its value to “0?.
This value is the amount of time the browser waits before it acts on information it recieves.
If you’re using a brodband connection you’ll load pages 2-3 times faster now.
1. Type “about:config” into the address bar and hit return. Scroll
down and look for the following entries:
network.http.pipelining
network.http.proxy.pipelining
network.http.pipelining.maxreq
Normally the browser will make one request to a web page at a time.
When you enable pipelining it will make several at once, which really
speeds up page loading.
2. Alter the entries as follows:
Set “network.http.pipelining” to “true”
Set “network.http.proxy.pipelining
Set “network.http.pipelining.maxre
means it will make 30 requests at once.
3. Lastly right-click anywhere and select New-> Integer.
Name it “nglayout.initialpaint.delay” and set its value to “0?.
This value is the amount of time the browser waits before it acts on information it recieves.
If you’re using a brodband connection you’ll load pages 2-3 times faster now.
Saturday, 23 February 2013
Sunday, 17 February 2013
Custom Exception Development:
Custom Exception
Development:
The new exception classes those are defined by developers
are called user Defined Exception or custom exception.
These classes must be subclass of either Throwable or any one of its subclass. It
must be thrown based on condition failure.
According to the business requirements developers must write
their own exception.
Its two steps process:
- Define public class deriving from java.lang.Exception.
- Define public no-arg and String parameter constructors with super() call.
For Example:
First Step:
NegativeNumberException.java
public class NegativeNumberException extends Exception
{
public
NegativeNumberException(){
super();
}
public
NegativeNumberException(String msg){
super(msg);
}
}
Using the above
custome Exception in Our logic
Compute.java
public class Compute
{
public
int add(int n)throws NegativeNumberException
{
if(n>0){
return
(n+10);
}
else
{
throw
new NegativeNumberException("Do Not Pass Number <=0");
}
}
}
Example.java
class Example
{
public
static void main(String[] args)
{
try{
int
n=Integer.parseInt(args[0]);
Compute
c=new Compute();
int
res=c.add(n);
System.out.println("Result::"+res);
}
catch(ArrayIndexOutOfBoundsException
aiobe){
System.out.println("Pleas
pass ONE positive Integer number");
}
catch(NumberFormatException
nfe){
System.out.println("Pleas
pass only integer number");
}
catch(NegativeNumberException
nne){
System.out.println(nne.getMessage());
}
}
}
Saturday, 16 February 2013
Marker Interface
Marker Interface: an interface that is used to check/mark/tag the given object is of a specific type to perform a special operations on that object, is called marker interface. Marker interface will not have methods, they are empty interfaces.
It is used to check whether we can perform some special operations on the passed object.
For example:
If class is deriving from java.io.Serializable, then that class object can be serializable else it cannot.
If class is deriving from java.lang.Clonable, then that class object can be cloned, else it cannot.
In side those particular methods, that method developer will check that the passed object is of type the given interface or not by using instanceof operator.
Write an empty interface and use in the method to check the passed object is of type the interface or not by using “instanceof” operator.
Is empty interface a marker interface?
Depends, if it is using in instanceof operator condition it called marker else it is call empty interface.
Predefined marker interface:
1. Java.lang.Clonable
2. Java.io.Serializable
3. Java.util.RandomAccess
4. Java.rmi.Remote
5. Javax.servlet.SingleThreadModel
6. Java.util.EventListener
It is used to check whether we can perform some special operations on the passed object.
For example:
If class is deriving from java.io.Serializable, then that class object can be serializable else it cannot.
If class is deriving from java.lang.Clonable, then that class object can be cloned, else it cannot.
In side those particular methods, that method developer will check that the passed object is of type the given interface or not by using instanceof operator.
Write an empty interface and use in the method to check the passed object is of type the interface or not by using “instanceof” operator.
Is empty interface a marker interface?
Depends, if it is using in instanceof operator condition it called marker else it is call empty interface.
Predefined marker interface:
1. Java.lang.Clonable
2. Java.io.Serializable
3. Java.util.RandomAccess
4. Java.rmi.Remote
5. Javax.servlet.SingleThreadModel
6. Java.util.EventListener
Friday, 15 February 2013
Delete administrator Password
How to "Delete administrator Password" without any software
Method 1:
Boot up with DOS and delete the sam.exe and sam.log files from Windows\system32\config in your hard drive. Now when you boot up in NT the password on your built-in administrator account which will be blank (i.e No password). This solution works only if your hard drive is FAT kind.
Method 2:
Step 1. Put your hard disk of your computer in any other pc .
Step 2. Boot that computer and use your hard disk as a secondaryhard disk (D'nt boot as primary hard disk ).
Step 3. Then open that drive in which the victim’s window(or your window) is installed.
Step 4. Go to location windows->system 32->config
Step 5. And delete SAM.exe and SAM.log
Step 6. Now remove hard disk andput in your computer.
Step 7. And boot your computer:-)
Method 1:
Boot up with DOS and delete the sam.exe and sam.log files from Windows\system32\config in your hard drive. Now when you boot up in NT the password on your built-in administrator account which will be blank (i.e No password). This solution works only if your hard drive is FAT kind.
Method 2:
Step 1. Put your hard disk of your computer in any other pc .
Step 2. Boot that computer and use your hard disk as a secondaryhard disk (D'nt boot as primary hard disk ).
Step 3. Then open that drive in which the victim’s window(or your window) is installed.
Step 4. Go to location windows->system 32->config
Step 5. And delete SAM.exe and SAM.log
Step 6. Now remove hard disk andput in your computer.
Step 7. And boot your computer:-)
Wecome Note
It’s a simple trick to amaze your friends.When you Log On infront of them.
Yeah a trick to make your Computer Welcome you on StartUp.
Follow this tricks /b>
Open Notepad
Paste the bellow code.
Dim speaks, speech
speaks="Welcome Back, Netricks"
Set speech=CreateObject("sapi.spvo ice")
speech.Speak speaks
step2:now,Replace Netricks withyour Name
Click Save As and rename as Welcome.vbs
Copy File Welcome.vbs and paste it in bellow address
Windows-7
C:Users/Netricks/AppData/Roaming/M icrosoftWindows/Start Menu/ProgramsStartup
Replace Netricks with your username and C: with your RootDrive
Windows-Xp
documents and SettingsAll UsersStart MenuProgramsStartup
Done Log Off and Log In Amazed?
Now Your Pc welcomes you.
Yeah a trick to make your Computer Welcome you on StartUp.
Follow this tricks /b>
Open Notepad
Paste the bellow code.
Dim speaks, speech
speaks="Welcome Back, Netricks"
Set speech=CreateObject("sapi.spvo
speech.Speak speaks
step2:now,Replace Netricks withyour Name
Click Save As and rename as Welcome.vbs
Copy File Welcome.vbs and paste it in bellow address
Windows-7
C:Users/Netricks/AppData/Roaming/M
Replace Netricks with your username and C: with your RootDrive
Windows-Xp
documents and SettingsAll UsersStart MenuProgramsStartup
Done Log Off and Log In Amazed?
Now Your Pc welcomes you.
Tuesday, 12 February 2013
Saturday, 9 February 2013
JPA
The Java Persistence API is enabling us to
create the persistence layer for desktop and web applications.
JCA
Java Cryptography Architecture term from Sun for
implementing security functions for the Java platform. It provides a platform
and gives architecture and APIs for encryption and decryption.
Friday, 8 February 2013
In Java, how does System.out.println() work?
In Java, how does System.out.println() work?
|
Marcus Aurelius (a Roman emperor) once said: "Of each particular thing ask: what is it in itself? What is its nature?". This problem is an excellent example of how that sort of thinking can help one arrive at an answer with only some basic Java knowledge.
With that in mind, let’s break this down, starting with the dot operator. In Java, the dot operator can only be used to call methods and variables so we know that ‘out’ must be either a method or a variable. Now, how do we categorize ‘out’? Well, ‘out’ could not possibly be a method because of the fact that there are no parentheses – the ‘( )’ – after ‘out’, which means that out is clearly not a method that is being invoked. And, ‘out’ does not accept any arguments because only methods accept arguments – you will never see something like “System.out(2,3).println”. This means ‘out’ must be a variable.
We now know that ‘out’ is a variable, so we must now ask ourselves what kind of variable is it? There are two possibilities – it could be a static or an instance variable. Because ‘out’ is being called with the ‘System’ class name itself, and not an instance of a class (an object), then we know that ‘out’ must be a static variable, since only static variables can be called with just the class name itself. So now we know that ‘out’ is a static member variable belonging to the System class.
Breaking down the “out” in System.out.println
Noticing the fact that ‘println()’ is clearly a method, we can further classify ‘out’. We have already reasoned that ‘out’ is a static variable belonging to the class System. But now we can see that ‘out’ must be an instance of a class, because it is invoking the method ‘println()’.The thought process that one should use to arrive at an answer is purposely illustrated above. Without knowing the exact answer beforehand, you can arrive at an approximate one by applying some basic knowledge of Java. Most interviewers wouldn’t expect you to know how System.out.println() works off the top of your head, but would rather see you use your basic Java knowledge to arrive at an answer that’s close to exact.
When and where is the “out” instantiated in System.out.println?
When the JVM is initialized, the method initializeSystemClass() is called that does exactly what it’s name says – it initializes the System class and sets the out variable. The initializeSystemClass() method actually calls another method to set the out variable – this method is called setOut().The final answer to how system.out.println() works
The more exact answer to the original question is this: inside the System class is the declaration of ‘out’ that looks like: ‘public static final PrintStream out’, and inside the Prinstream class is a declaration of ‘println()’ that has a method signature that looks like: ‘public void println()’.Here is what the different pieces of System.out.println() actually look like:
//the System class belongs to java.lang package class System { public static final PrintStream out; //... } //the Prinstream class belongs to java.io package class PrintStream{ public void println(); //... }
Thursday, 7 February 2013
secure Google Chrome with password.
We can protect our Google Chrome with Password. We can secure Saved Password,
Important Bookmarks, etc... with this "Simple Password Startup" Extension. So let's see how to
secure Google Chrome with password.
|:|:|:|:|: Secure your Google Chrome with Password:|:|:|:|
Install the "Simple Password Startup" Extension in your Chrome
Click here to Install
Then go to "Tools" --> "Extension" --> "Simple Password Startup" --> "Option"
After that Enter a Password and Save it.
Now your Google Chrome is secured with Password.
Important Bookmarks, etc... with this "Simple Password Startup" Extension. So let's see how to
secure Google Chrome with password.
|:|:|:|:|: Secure your Google Chrome with Password:|:|:|:|
Install the "Simple Password Startup" Extension in your Chrome
Click here to Install
Then go to "Tools" --> "Extension" --> "Simple Password Startup" --> "Option"
After that Enter a Password and Save it.
Now your Google Chrome is secured with Password.
Secure your Google Chrome with Password
If you want to open your Google Chrome, every time you have to type the password in home
page. If you type a wrong password, Chrome will be closed. Without knowing the password we
can see only the "Home page" in chrome.
Secure your Google Chrome with Password
This is a very easiest way to protect your "Saved Password" and "Bookmarks" from unknown persons.
Note: Don't forget your Startup password, if you forget the password, you can't recover it.
If you want to open your Google Chrome, every time you have to type the password in home
page. If you type a wrong password, Chrome will be closed. Without knowing the password we
can see only the "Home page" in chrome.
Secure your Google Chrome with Password
This is a very easiest way to protect your "Saved Password" and "Bookmarks" from unknown persons.
Note: Don't forget your Startup password, if you forget the password, you can't recover it.