Author Archive

How to enable gzip compression in jBoss?

To enable JBoss http protocol gzip compression you have to change the server.xml file.
Location:
Less than 4.0 Version : ${jBoss-home}\server\default\deploy\jbossweb-tomcat50.sar\server.xml
above 4.0 Version     : ${jBoss-home}\server\default\deploy\jboss-web.deployer\server.xml

Find this piece of xml code:
<Connector port=”8080″ address=”${jboss.bind.address}” maxThreads=”250″
maxHttpHeaderSize=”8192″ emptySessionPath=”true” protocol=”HTTP/1.1″
enableLookups=”false” redirectPort=”8443″ acceptCount=”100″ connectionTimeout=”20000″
disableUploadTimeout=”true” compression=”0″></Connector>

When compression is disabled compression parameter is set to 0.
To enable compression set it to 1.

After that you can see the difference.
It can compress HTML,CSS,JavaScript,Images File from 1 MB to around 300kb.

Popularity: 4% [?]

What is Generics in java?

Generics:

Generics provides compile-time (static) type safety for collections and
eliminates the need for most typecasts (type conversion).

For Example:

List<String> stringList = new ArrayList<String>();
stringList.add(“one”);
stringList.add(“two”);
stringList.add(“three”);
stringList.add(“four”);
stringList.add(“five”);

In the above example,we can add only the String in a ArrayList.If we add
Other than String mean it’s throw an error.

Other Uses Of Generics are:
In For loop we directly use without checking condition of length.

Example:
Previously Used For Loop:
========================
String value=”";
for(int i=0;i<stringList.length();i++)
{
value=(String)stringList.get(i);
System.out.println(value);
}

Generic For Loop
================
for(String value : stringList)
{
System.out.println(value);
}

Popularity: 2% [?]

What is JQuery?

  • It is a new kind of JavaScript Library.
  • It is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
  • It designed to change the way that you write JavaScript.
  • Light Weight Component
  • Support CSS 1-3 selectors
  • Support cross-browser

Popularity: 1% [?]

How to deploy WAR/JAR File in JBOSS

Step to deploy WAR/JAR File in JBOSS

  • Paste your WAR/JAR File into jboss\server\default\deploy Folder
  • Go to jboss\bin and run the file run.bat.
  • After successful run.go to jboss\server\default folder and see three new folder log,tmp,work.
  • log – Log File is created here
  • tmp – All the Deployed WAR and JAR File extacted here.
  • work – all the code in a servlet form maintain here.

Popularity: 3% [?]

Difference between String and String Buffer

String
=====
String are immutable object.Its value cannot be changed(constant).String object are readonly.If you create one instance of string and change the value of string then it create new instance.

String Buffer
=========
String Buffer is mutable.Its Value can be Changed.If you create one instance and append the text without creating a new instance

Example:
======
String
=====
String str=”welcome”;
str + = “to fordevs”;

String Buffer
=========
StringBuffer strbuff=new StringBuffer(“welcome”);
strbuff.append(“to fordevs”);

Both code give same output but Second approach much faster than first one.

Popularity: 6% [?]

How to find 2nd highest value in a table ?

To Find the 2nd Maximum Of Mark in a Data Set

SELECT * FROM Student a WHERE 2=(SELECT COUNT(DISTINCT Mark)
FROM Student b WHERE a.Mark&lt;=b.Mark)

To Find the 2nd Minimum Of Mark in a Data Set

SELECT * FROM Student a WHERE 2=(SELECT COUNT(DISTINCT Mark)
FROM Student b WHERE a.Mark&gt;=b.Mark)

To Find nth Maximum and Minimum

SELECT * FROM Student a WHERE n=(SELECT COUNT(DISTINCT Mark)
FROM Student b WHERE a.Mark&lt;=b.Mark)
SELECT * FROM Student a WHERE n=(SELECT COUNT(DISTINCT Mark)
FROM Student b WHERE a.Mark&gt;=b.Mark)

replace n with the corresponding number

Popularity: 2% [?]

How to convert from .class file to .java file in Java

Step 1: Download Java – Decompiler from

http://download.cnet.com/windows/3055-2213_4-10046809.html?tag=pdl-redir

Step 2: Install the Java – Decompiler in your PC.

Step 3: Go to All Programs –> DJ Java Decomplier –> DJ Java Decomplier.

Step 4: Select File –> Open then Choose the Class File in File Dialog box.

djopendialogjpg

Step 5: Java File is created from class File.

javafilejpg

Popularity: 16% [?]

Java 1.5 features

  • Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
  • Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
  • Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
  • Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
  • Swing: new skinnable look and feel, called synth.
  • Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string… Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
  • Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
  • Automatic stub generation for rmi objects.
  • Static imports concurrency utilities in package java.util.concurrent.
  • Scanner class for parsing data from various input streams and buffers.
  • Assertions
  • StringBuilder class (in java.lang package)

Popularity: 11% [?]

Java with JDBC

Combination of java and JDBC is very useful to lets the programmer run his/her program on different platforms. Java programs are secure, robust, automatically downloaded from the network.JDBC API enables Java applications to interact with different types of databases.

Some of the advantages of using Java with JDBC are
• Easy and economical
• Continued usage of already installed databases
• Development time is short
• Installation and version control simplified

JDBC does the following three things
• Establish connection with a database
• Send SQL statements
• Process the results

Popularity: 2% [?]

Java Networking

Network is nothing but a set of computers which are physically connected together.internet is a network of networks.

Protocols:
Different networks requires certain set of rules called protocols.java networking is done using TCP/IP protocol

Different types of protocols are also available in this protocol they are:

*Http(Hyper Text Transfer Protocol)
*FTP(File Transfer Protocol)
*SMTP(Simple Mail Transfer Protocol)
*NNTP(Network News Transfer Protocol)

Sockets:
Sockets is used to plug in just like a electronic sockets.it is essential that they should follow a set of rules to communicate called protocols.
TCP/IP as protocol for communication and IP addresses are the address of the sockets.

Client/Server:
A computer request some service from another computer,is called a client.one that processes the request is called server.A server waits till one of its clients makes a request.it can accept multiple connections at a time.Multi-threading is used to serve multiple users at the same time.

Internet Addresses:

Every computer are connected to a network has a unique IP address.An IP address is a 32-bit number which has four numbers separate by periods.it is possible to connect to the Internet either directly or by using internet service provider.By connecting directly to the internet,the computer is assigned with a permanent IP address.

InetAddress:
InetAddress is one class,which is used to encapsulate th IP address and the DNS.to create a instance of InetAddress class,factory methods are used as there are no visible constructors available for this class.

Methods:

static InetAddress getLocalHost()
//Returns InetAddress object representing local host
static InetAddress getByName(String hostname)
//Returns InetAddress for the host passed to it.

Popularity: 1% [?]

Designed by: Business Web Hosting | Thanks to Buy Icons, travel tips and Used Cars