Thursday, October 15, 2009

Unique Example of synchronized threads with MouseListener

Ide@: Arindam Mitra



Below source code is an example of you can manage synchronization of a continuous thread of MouseEntered event with a user defined thread of MouseExited event.



MouseListener interface has abstract methods out of which mouseEntered and mouseExited are the two methods. Suppose, in a JWindow, you have a JProgressBar. When you enter your mouse in the JWindow, it will continuously progress the status of the progress bar. However, if you remove the mouse from the window, progress bar will stop progressing and halts the current status.



Below is the source code. Hope you like it.



import java.awt.*;
import java.awt.event.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JWindow;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class WindowProgressBarThread extends JFrame implements MouseListener, ActionListener, Runnable {
JLabel label;
JButton buttonClick;
JButton buttonClose;
JWindow window;
JProgressBar jProgressBar = new JProgressBar();
private static int statusInt = 0;
private Thread runner;
// A thread that runs as long as the timer
// is running. It sets the text in the label
// to show the elapsed time. This variable is
// non-null when the timer is running and is
// null when it is not running. (This is
// tested in mousePressed().)

// Constants for use with status variable.
private static final int GO = 0, TERMINATE = 1;

private int status;
// This variable is set by mouseEntered() and mouseExited()
// to control the thread. When it's time
// for the thread to end, the value is
// set to TERMINATE.

public WindowProgressBarThread() {

buttonClick = new JButton(" Click On It ");
buttonClose = new JButton("Close");
jProgressBar.setMaximum(100);
jProgressBar.setMinimum(0);
window = new JWindow();

JPanel panel = new JPanel(new GridLayout(1, 0));
JFrame.setDefaultLookAndFeelDecorated(true);
this.setLayout(new BorderLayout());
this.setDefaultLookAndFeelDecorated(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

panel.add(buttonClick);

this.add(panel, BorderLayout.LINE_START);



this.setSize(200,75);
this.pack();
this.setVisible(true);
this.setResizable(false);
this.setLocationRelativeTo(null);

window.addMouseListener(this);
buttonClick.addActionListener(this);
buttonClose.addActionListener(this);

}


// Run method executes while the timer is going.
// Several times a second, it computes the number of
// seconds the thread has been running and displays the
// whole number of seconds on the label. It ends
// when status is set to TERMINATE.
public void run() {
while (true) {
synchronized(this) {
if (status == TERMINATE) {
break;
}
if(statusInt <= 99) { statusInt = statusInt + 1; jProgressBar.setValue(statusInt); jProgressBar.setString(statusInt + "%"); jProgressBar.setStringPainted(true); } } waitDelay(100); } } synchronized void waitDelay(int milliseconds) { // Pause for the specified number of milliseconds OR // until the notify() method is called by some other thread. // (From Section 7.5 of the text.) try { wait(milliseconds); } catch (InterruptedException e) { } } public void mousePressed(MouseEvent evt) { } public void mouseReleased(MouseEvent evt) { } public void mouseClicked(MouseEvent evt) { } synchronized public void mouseEntered(MouseEvent evt) { status = GO; runner = new Thread(this); runner.start(); // start the runner thread (can call it child thread) } synchronized public void mouseExited(MouseEvent evt) { status = TERMINATE; notify(); // Wake up the main thread so that child thread can terminate quickly. jProgressBar.setValue(statusInt); jProgressBar.setString(statusInt + "%"); jProgressBar.setStringPainted(true); runner = null; // stop the runner thread (can call it child thread) } public void actionPerformed(ActionEvent ae) { if(ae.getSource()==buttonClick) { buttonClick.setEnabled(false); statusInt = 0; jProgressBar.setValue(statusInt); jProgressBar.setString(statusInt+"%"); jProgressBar.setStringPainted(true); window.add(new JLabel("Progress Bar Demo",SwingConstants.CENTER), BorderLayout.NORTH); window.add(jProgressBar, BorderLayout.CENTER); window.add(buttonClose, BorderLayout.SOUTH); window.pack(); window.setBounds(800, 500, 200, 75); window.setVisible(true); } if(ae.getSource()==buttonClose){ buttonClick.setEnabled(true); window.setVisible(false); } } public static void main(String[] args) { WindowProgressBarThread windoeProgressThread = new WindowProgressBarThread(); } }


Simple Ajax Example of UserName and Password Validations

Below set of codes are the examples of Ajax which takes the username and password from a XML file stored in the server directory.

Below example has a parent window, where an Edit Label is there. On click on Edit Label, it will go to a child window and will have provision to enter username and password. The username and password, entered, will be checked with those of parent window, which has been populated from a XML file using Ajax.

Before going into the code, let’s have some basics of Ajax:

AJAX is Asynchronous JavaScript and XML and based on JavaScript and HTTP requests. With AJAX, a JavaScript can communicate directly with the server, with the XMLHttpRequest object. With this object, a JavaScript can trade data with a web server, without reloading the page.

AJAX uses asynchronous data transfer (HTTP requests) between the browser and the web server, allowing web pages to request small bits of information from the server instead of whole pages.

Source Codes:

This example consists of five jsps and one Credentials.xml [in the server directory]

testAjax.jsp, time.jsp, EnterCredentials.jsp, UserName.jsp, Password.jsp

If the username and password matches with the one which are stored in the server, it will automatically check the checkbox in the parent window.

testAjax.jsp



time.jsp



EnterCredentials.jsp




UserName.jsp



Password.jsp




Credentials.xml in the server directory






Java Source Code to find the IP Address of the machine

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;

public class ipfind {

ipfind(){

try{
Enumeration e = NetworkInterface.getNetworkInterfaces();
while(e.hasMoreElements()){
NetworkInterface ni = (NetworkInterface)e.nextElement();
Enumeration e1 = ni.getInetAddresses();
while(e1.hasMoreElements()){
InetAddress inetAddress = (InetAddress)e1.nextElement();
System.out.println(" " + inetAddress.getHostAddress());
}

}
}catch(Exception e){

}
}

public static void main(String args[]){
ipfind ipf = new ipfind();
}
}

Wednesday, October 14, 2009

Add Swing Components Dynamically using Array List

Below code is to add swing components (button and textfield) dynamically using ArrayList.


import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRootPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class ButtonAddDynamic implements ActionListener{

public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new ButtonAddDynamic().createAndShowGUI();
}
});
}

private JFrame frame;
private JPanel panel = new JPanel(new GridBagLayout());
private GridBagConstraints constraints = new GridBagConstraints();

private List fields = new ArrayList();
private List fieldButton = new ArrayList();
private List fieldFile = new ArrayList();

private JButton button1 = new JButton("Add Another TextField and Button");
private static int countReport = 0;
String files = null;
int y=2;

protected void createAndShowGUI() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (UnsupportedLookAndFeelException ex) {
ex.printStackTrace();
} catch (InstantiationException ex) {
ex.printStackTrace();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (IllegalAccessException ex) {
ex.printStackTrace();
}

String[] labels = { "Locations of the given input" };
for (String label : labels)
addColumn(label);
addRowBelow();
constraints.gridx=1;
constraints.gridy=0;
panel.add(button1,constraints);

frame = new JFrame("Add Button Dynamically");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JScrollPane(panel));
frame.setLocationRelativeTo(null);
frame.setResizable(false);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
button1.addActionListener(this);

//Set the default button to button1, so that when return is hit, it will hit the button1

JRootPane root = frame.getRootPane();
root.setDefaultButton(button1);
frame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
System.exit(0);
}
});
}


private void addColumn(String labelText) {
constraints.gridx = fields.size();
constraints.gridy = 1;
panel.add(new JLabel(labelText), constraints);
constraints.gridy=2;
final JTextField field=new JTextField(40);
field.setEditable(false);
panel.add(field,constraints);
fields.add(field);

//constraints.gridy=3;
constraints.gridx = fields.size() + fieldButton.size();
JButton button = new JButton("OK");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
JOptionPane.showMessageDialog(null,"Program to add swing components dynamically","HI",1);
}
}
);
panel.add(button,constraints);
fieldButton.add(button);
panel.revalidate(); // redo layout for extra column
}


private void addRowBelow() {
y++;
constraints.gridy=y;
//System.out.println(fields.size());
for (int x=0;x < fields.size();x++) {
constraints.gridx=x;
final JTextField field = new JTextField(40);
field.setEditable(false);
panel.add(field, constraints);
constraints.gridx=x+1;
JButton button = new JButton("OK");
button.addActionListener(new ActionListener()
{ public void actionPerformed(ActionEvent ae){
JOptionPane.showMessageDialog(null,"Program to add swing components dynamically","HI",1);
}
}
);
panel.add(button,constraints);
}
}

public void actionPerformed(ActionEvent ae){
if("Add Another TextField and Button".equals(ae.getActionCommand())) {
addRowBelow();
frame.pack();
frame.setLocationRelativeTo(null);
}
}
}

Java Source Code – Slowly Closing the Window of a JFrame – Tricks

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;


public class SlowClose {
public SlowClose() {

final JFrame jFrame = new JFrame();
jFrame.setSize(500,350);
jFrame.setVisible(true);
jFrame.setResizable(false);
jFrame.setLocationRelativeTo(null);
jFrame.setTitle("SlowClose");


jFrame.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent we){
int x = 500;
int y = 350;
int d = 10;
while(x > 100 && y > 50){
x = x-d;
y = y-d;
jFrame.setSize(x,y);
System.out.println("X = " + x + "Y = " + y);
try{
Thread.sleep(10000);
}catch(InterruptedException ie){
ie.printStackTrace();
}

if(x <= 100 y <= 50){
System.exit(0);
}
}
}
});
}

public static void main(String args[]) {
SlowClose slowClose = new SlowClose();
}

}

Nobel Winners - 2009

Physics

Charles K. Kao – for groundbreaking achievements concerning the transmission of light in fibers for optical communication - China
Willard S. Boyle
– for the invention of an imaging semiconductor circuit – the CCD sensor - USA
George E. Smith – for the invention of an imaging semiconductor circuit – the CCD sensor - USA

Chemistry [for studies of the structure and function of the ribosome]

Venkatraman RamakrishnanUK
Thomas A. Steitz - USA
Ada E. YonathIsrael

Physiology or Medicine [for the discovery of how chromosomes are protected by telomeres and the enzyme telomerase]

Elizabeth H. Blackburn - USA
Carol W. Greider - USA
Jack W. Szostak - USA

Literature[ who, with the concentration of poetry and the frankness of prose, depicts the landscape of the dispossessed]

Herta MüllerGermany

Peace – [for his extraordinary efforts to strengthen international diplomacy and cooperation between peoples]

Barrack ObamaUSA

The Sveriges Riksbank Prize in Economic Sciences in Memory of Alfred Nobel

Elinor Ostrom - for her analysis of economic governance, especially the commons - USA
Oliver E. Williamson - for his analysis of economic governance, especially the boundaries of the firm - USA

[Source:nobelprize.org]

Saturday, October 10, 2009

SSL Implementation – Java Source Code

In my earlier article, I have given the highlights the basics of one way and two way ssl.
This article will help you to implement one way SSL and two way SSL using Java.

Before proceeding into the codes, I would like to explain few terms and concepts which will help you to understand the code in a better way.

Using certificates for privacy and security

You can use certificates to protect your personally identifiable information on the Internet and to protect your computer from unsafe software. A certificate is a statement verifying the identity of a person or the security of a Web site.

Internet Explorer uses two different types of certificates:


A personal certificate is a verification that you are who you say you are. This information is used when you send personal information over the Internet to a Web site that requires a certificate verifying your identity. You can control the use of your identity by having a private key on your computer. When used with e-mail programs, security certificates with private keys are also known as "digital IDs".


A Web site certificate states that a specific Web site is secure and genuine. It ensures that no other Web site can assume the identity of the original secure site. When you are sending personal information over the Internet, it is a good idea to check the certificate of the Web site you are using to make sure that it will protect your personally identifiable information. When you are downloading software from a Web site, you can use certificates to verify that the software is coming from a known, reliable source.

[Source: Microsoft Internet Explorer Help]

How do security certificates work?

A security certificate, whether it is a personal certificate or a Web site certificate, associates an identity with a public key. Only the owner of the certificate knows the corresponding private key. The private key allows the owner to make a digital signature or decrypt information encrypted with the corresponding public key. When you send your certificate to other people, you are actually giving them your public key, so they can send you encrypted information that only you can decrypt and read with your private key.

The digital signature component of a security certificate is your electronic identity card. The digital signature tells the recipient that the information actually came from you and has not been forged or tampered with.

Before you can start sending encrypted or digitally signed information, you must obtain a certificate and set up Internet Explorer to use it. When you visit a secure Web site (one whose address starts with https), the site automatically sends you its certificate.

[Source: Microsoft Internet Explorer Help]

KeyStore and TrustStore

A keystore contains a private key. You only need this if you are a server, or if the server requires client authentication.

A truststore contains CA certifcates to trust. If your server's certificate is signed by a recognized CA, the default truststore will already trust it (because it already trusts trustworthy CAs), so you don't need to build your own, or to add anything to the one from the JRE.

You always need a truststore that points to a file containing trusted certificates, no matter whether you are implementing the server or the client side of the protocol, with one exception. This file is often has a name like cacerts, and by default it may turn out to be a file named cacerts in your jre security directory.

You may or may not need a keystore. The keystore points to a file containing private key material. You need a keystore if 1) you are implementing the server side of the protocol, or 2) you are implementing the client side and you need to authenticate yourself to the server.

SSL provides you with privacy, integrity, and authentication. That is, the messages are encrypted, tamper-evident, and come from an authenticated identity. Whether that's the identity you want to talk to is another question. So the application has to perform the authorization step, i.e. check the identity against what is expected. You do this by getting the peer certificates out of the SSLSession, usually in a HandshakeCompletedListener, and check that the identity of the server is what you expect. SSL can't do this for you as only the application knows who it expects to talk to. Another way around this is to ship a custom truststore that only contains the server certificate for the correct server, so it won't trust anybody else.

AccessUrlSSL.java

/*
Implementation of one way and two way SSL using Java
You can change the mode of the program from one way SSL to two way SSL by changing the flag "oneWaySSL"
If oneWaySSL = true then OneWaySSL, if false then Two Way SSL.

If you need to give proper URL.

Also you need to set the property of:

1. TrustStore location and TrustStore Password to implement one way ssl.
2. KeyStore Location, KeyStorePassword and TrustStore Location, TrustStorePassword to implement two way ssl.
*/
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;

public class AccessUrlSSL{

AccessUrlSSL(){
}

private void doUpload(){
boolean oneWaySSL = false; // One Way SSL [true] and Two Way SSL [false]
if(oneWaySSL){
HostnameVerifier hv = new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
return true;
}
};
HttpsURLConnection.setDefaultHostnameVerifier(hv);
}
try {
System.setProperty("https.proxySet","true");
System.setProperty("https.proxyHost","internet proxy address");
System.setProperty("https.proxyPort","8080");
System.setProperty("https.proxyType","4");
if(oneWaySSL){
System.setProperty("javax.net.ssl.trustStore","trustStoreLocation");
System.setProperty("javax.net.ssl.trustStorePassword","passw0rd");
}else{
System.setProperty("java.protocol.handler.pkgs","javax.net.ssl");
System.setProperty("javax.net.ssl.keyStore","keystoreLocation"); //KeyStoreLocation - contains the private keys
System.setProperty("javax.net.ssl.keyStorePassword","passw0rd");
System.setProperty("javax.net.ssl.trustStore","trustStoreLocation"); //TrustStoreLocation - contains the trusted sites
System.setProperty("javax.net.ssl.trustStorePassword","passw0rd");
}

if(oneWaySSL){
URL url = new URL("https","siteLocation",443,"siteFolder");
} else {
URL url = new URL("https","siteLocation",443,"siteFolder");
}
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Type", "multipart/form-data;boundary=vxvxv");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String str = "";
boolean startPrint = false;
while ((str = in.readLine()) != null) {
System.out.println(str);
}
in.close();
} catch (MalformedURLException me) {
me.printStackTrace();
} catch (IOException ie) {
ie.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
}

public static void main(String args[]){
AccessUrlSSL accessUrlSSl = new AccessUrlSSL();
accessUrlSSl.doUpload();
}

}

Suggestions and feedback please.

Thursday, October 8, 2009

One Way SSL and Two Way SSL

The Secure Sockets Layer (SSL) is a mostly used protocol for managing the security of transmission of a message on the Internet. SSL uses a program layer located between the Internet's Hypertext Transfer Protocol (HTTP) and Transport Control Protocol (TCP) layers.

Here in this article we are mainly concerned about the transmission of message between a SSL client and SSL server. There are two ways how SSL can be implemented between a client and a server. They are: One Way SSL and Two Way SSL.
One Way SSL:
One way SSL authentication enables a application to authenticate or identify itself to the user (client).

The best example of a one way SSL authentication is internet banking sites. Whenever you open those kinds of sites, it will generally ask for a warning. This warning pop up will also show you certificates. These certificates are the authentication of the application which you want to access. If you see, there is a lock sign at the right bottom corner of the status bar of the browser. If you double click on it, you will get all the details of the certificates. The certificates have expiry date and issuing authority details, which will confirm you the identification of the application.

Now technically speaking,
The application which we are going to connect is SSL server and the browser which will connect to the application is a SSL client. SSL client initiates a contact with a SSL server. The SSL server presents a signed certificate (public key) to the SSL client. SSL client verifies the identity of the server with the private key of the server stored in it (client) and the authentication is complete.




Two Way SSL:


In Two way SSL implementation as its name suggests that not only the client authenticates the server, however server also authenticates to the client. Hence, unlike above, here in both server and client, certificates are present and client application verifies the identity of server application and server application also verifies the identity of the client application.




As said above, here not only the server authenticates to the client, also client authenticates itself to the server, that’s why two way SSL is also referred to as client authentication.




The example of two way SSL would be applications which deals with sensitive and confidential data which is intended for a particular recipients. Thus the client who is having the certificates to authenticate itself to the server will only be able to access the application.



In the two way SSL applications, SSL client initiates a connection to a SSL server and server is set to use two way SSL client authentication. The SSL server presents it certificate [which is a public key of the server] to the client for verification. The SSL client verifies it with the private key store of the server. Then SSL server requests SSL client to send its public key to the SSL server to verify with the private key of the SSL client stored in the SSL server.



Any suggestions would very much be appreciated.

Tuesday, October 6, 2009

Create New Sheets in Excel with Name from A to Z using VBA

Below is the VBA code [to be put into the macro] which creates sheets with name "A" to "Z" in a excel work book.

For my ease, I have created a button on the click of which all the sheets will be created.

To create the button, the code is :

Sub AddButton()
Set btn = ActiveSheet.Buttons.Add(0, 90, 100, 25)
btn.OnAction = "CreateNewSheet"
btn.Characters.Text = "CreateSheets"
End Sub


To create sheets:
Sub CreateNewSheet()
For i = 65 To 90
Sheets.Add.Name = Chr(i) ' Ascii representation of A to Z is 65 to 90
Next i
End Sub

Java Source Code to access the Active Directory Server

Active Directory:
Active Directory is a directory structure created by Microsoft that provides a variety of network services, including LDAP-like directory services.

An active directory (sometimes referred to as an AD) does a variety of functions including the ability to provide information on objects, helps organize these objects for easy retrieval and access, allows access by end users and administrators and allows the administrator to set security up for the directory.

An active directory can be defined as a hierarchical structure and this structure is usually broken up into three main categories, the resources which might include hardware such as printers, services for end users such as web email servers and objects which are the main
functions of the domain and network.
LDAP:
LDAP (Lightweight Directory Access Protocol) is a protocol for communications between LDAP servers and LDAP clients. LDAP servers store "directories" which are access by LDAP clients.

LDAP is called lightweight because it is a smaller and easier protocol which was derived from the X.500 DAP (Directory Access Protocol) defined in the OSI network protocol stack.

LDAP servers store a hierarchical directory of information. In LDAP parlance, a fully-qualified name for a directory entry is called a Distinguished Name. Unlike DNS (Domain Name Service) FQDN's (Fully Qualified Domain Names), LDAP DN's store the most significant data to the right.

[Source: Internet]
The Java source code which I am going to write will connect to the Active Directory Server of web email server configured in the Microsoft Exchange Outlook.

Before going into the code, below are the steps which might reveal the LDAP server name in the MS outlook client.









Click on the properties
The RED colored portion would be our LDAP server name





Below is the code to connect to LDAP server.

ActiveDirectoryDemo.java

import java.util.Hashtable;
import javax.naming.ldap.*;
import javax.naming.directory.*;
import javax.naming.*;

public class ActiveDirectoryDemo {
public static void main(String[] args) {
Hashtable env = new Hashtable();
env.put(Context.SECURITY_PRINCIPAL,"CN=username,OU=companynameOU,DC=company name.com");//User
env.put(Context.SECURITY_CREDENTIALS, "password");//Password
env.put(Context.REFERRAL, "follow");
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, "ldap://servername.Company name.com:port number = 389");
env.put(Context.SECURITY_AUTHENTICATION,"none");
try {
LdapContext context = new InitialLdapContext(env, null);
String base = "";
String filter = "(objectclass=*)";
SearchControls controls = new SearchControls();
controls.setSearchScope(SearchControls.OBJECT_SCOPE);
NamingEnumeration answer = context.search(base, filter, controls);

// ... process attributes ...
while (answer.hasMoreElements()) {
SearchResult sr = (SearchResult)answer.next();
System.out.println("RootDSE: " + sr.getName());

Attributes attrs = sr.getAttributes();
if (attrs != null) {
try {
System.out.println("Naming Context: " + attrs.get("defaultNamingContext").get());
System.out.println("Schema Context: " + attrs.get("schemaNamingContext").get());
System.out.println("DNS: " + attrs.get("dnsHostName").get());
System.out.println("Server Name: " + attrs.get("serverName").get());
}
catch (NullPointerException e) {
e.printStackTrace();
}
}
}
}
catch (NamingException e) {
e.printStackTrace();
}
}
}


Output:


Total Pageviews