Tuesday, 31 December 2013

Clear cache,saved password of remote machines in windows

Open a command prompt do this command:
net use
you get the list of saved connections AND of open sessions
c:\>net use
New connections will be remembered.
Status       Local     Remote                    Network
-------------------------------------------------------------------------------
Unavailable  J:        \\server\storedname       Microsoft Windows Network
Disconnected           \\server\IPC$             Microsoft Windows Network
The command completed successfully.
The "\server\IPC$" name is the session of which the password is remembered! Now with the command
net use \\server\IPC$ /delete
you will delete the cached password without the need of a logout!

Tuesday, 24 December 2013

A mostly asked interview question --- Is Java a pure object oriented language?

Java is not a pure object oriented language because it supports Primitive datatype such as int, byte, long… etc, to be used, which are not objects.

There are seven qualities to be satisfied for a programming language to be pure Object Oriented. They are:

1. Encapsulation/Data Hiding
2. Inheritance
3. Polymorphism
4. Abstraction
5. All predifined types are objects
6. All operations are performed by sending messages to objects
7. All user defined types are objects.

Thursday, 19 December 2013

how to know application or process running with which PID




Process identifier, or more commonly know as PID or process ID, is a unique number tagged with each processes running on a system, and used by some operating system kernels, such as UNIX, Linux, Mac OS X and Windows) to identify a process.

In Unix-like and Linux operating system, ps command can be used to search for the PID for a particular running process, by grepping the output. In Windows operating system such as Windows XP, Windows Vista, Windows Server 2003, Windows Server 2008 and Windows 7, there is no such utility or command available though.






In order to get to know, or view, retrieve and identify the process ID or PID of the processes running inWindows operating system, users or administrators can make use of Task Manager. However, Task Manager does not display PID information by default. To display the PID value in Task Manager, go toProcesses tab, click on View menu, then click on Select Columns…. In the “Select Columns” or “Select Process Page Columns” dialog, tick and check the checkbox for PID (Process Identifier), and click OK.


How to Check and Identify Which Application is Listening on Windows


Open Command Prompt window by typing Cmd in Run command box or Start Search, and hit Enter.
Type in the following netstat command:


netstat -o -n -a | findstr 0.0:80


or


netstat -o -n -a | findstr 0.0:443


or simply,


netstat -aon


Note: The last command will list all connection that is listening, established, starting, closing and all other states, so the list is long, and user has to manually search for rows that has connection originating or targeting to 1270.0.1:80/443 or 0.0.0.0.80/443.
The following line(s) of results should be returned:


TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 8704


The last column of each row is the process identified (process ID or PID).
Identify which process or application is using the port by matching the PID against PID number in Task Manager.


Another alternative to determine and identify which application is using port 80 or 443 is by using Telnetapplication. Just type the following command to Telnet to the system in port 80 or 443:


telnet localhost 80


or,


telnet localhost 443


If the Telnet connection can be opened, normally the banner of the application which opens the port will be shown, and help user to identify which process that actually listening on the port.


Tip: The command above can be used to identify and check what processes is using any other ports too, such as 7 (Echo), 21 (FTP), 23 (Telnet), 25 (SMTP), 53 (DNS), 70 (Gopher), 79 (Finger), 107 (RTelnet), 110 (POP3), 119 (NNTP), 139 (NetBIOS), 143 (IMAP), 194 (IRC), 3128, 8080, 10000, and etc.

Tuesday, 3 December 2013

Spring Mvc : Exception: String can't be cast to object while submitting from jsp Illegel argument Exception .

You can use the concept of property editor .In this we can create our custom property editors.
Sometimes what happen when submitting action in jsp . We are using reference of another entities in our model attribute. At that time controller method is expecting object and jsp is providing string.So in that case we can use property editors.


public class ABCPropertyEditor extends PropertyEditorSupport {

    private AbcService abcService;

    public ABCPropertyEditor(AbcService abcService) {
        this.abcService= abcService;
    }

    @Override
    public void setAsText(String s) {            //getting id of embeded entity
        Abc abc = abcService.getAbc(s);     //get object from id using any ORM tool
        this.setValue(abc);                            //returning object
    }
}





In controller with the help of @InitBinder we can use this property editor which get called automatically as request comes from jsp:

@InitBinder
protected void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(Abc.class, new ABCPropertyEditor (abcService));
}

Calling a method from server side while jquery validation

You can use remote for calling server side method.
As in code given below:

Javascript code:

$(function() {
        $("#add").click(function() {
$('#addusers').validate(
      {
rules : {
          userName : {
required : true,
remote : '/abc/useravailability'
},
emailid : {
required : true,
email : true
},
password : {
required : true
}
},
messages : {
userName : {
remote : jQuery
.format("Username is not available")
}
},
highlight : function(element) {
$(element).closest(
'.control-group')
.removeClass(
'success')
.addClass('error');
},
success : function(element) {
element
.text('OK!')
.addClass('valid')
.closest(
'.control-group')
.removeClass(
'error')
.addClass('success');
}
});
});


And server side method:
@RequestMapping(value = "/useravailability", method = RequestMethod.GET)
public @ResponseBody
boolean getUserAvailability(@RequestParam("userName") String name) {
//write some code
return boolean;
}